【问题标题】:fread error when running a c++ project from github从 github 运行 c++ 项目时出现 fread 错误
【发布时间】:2015-05-06 11:09:38
【问题描述】:

我尝试在https://github.com/nasadi/Zambezi 上运行makefile。它显示如下错误:--“从 src/driver/buildContiguous.c:7:0 中包含的文件:src/shared/dictionary/Dictionary.h:在函数‘readDictionary’中:src/shared/dictionary/Dictionary.h: 132:8:警告:忽略 'fread' 的返回值,用属性 warn_unused_result [-Wunused-result] fread(&id, sizeof(int), 1, fp) 声明;" .谁能帮我运行程序。我需要安装任何软件包吗?我是 c 编程新手。

【问题讨论】:

    标签: c++


    【解决方案1】:

    其实这不是错误,而是警告。当编译器发出警告时,这意味着代码在语法上是正确的,但可能包含逻辑错误。 在您的情况下,编译器表示未检查 fread 函数的返回值。这种无知可能会导致一种情况,例如,遇到文件结尾,但程序不知道它并继续执行。因此,从文件中读取的变量有错误的值,错误(无效)的值可能会导致以后程序崩溃。

    总结一下,如果没有其他错误,那么你的程序就编译成功,可以运行了。

    【讨论】:

    • 程序显示错误为:/usr/bin/ld: cannot open output file out/driver/buildContiguous: No such file or directory collect2: error: ld returned 1 exit status
    • @Manaf Mh 你应该阅读这个:stackoverflow.com/questions/6264249/…
    • 我手动创建了目录并使用 github 上的另一个 makefile 更改了 makefile:gist.github.com/ludkiller/f4b86da7604497f99d40。但它仍然显示错误为:“make: *** No rule to make target `all'. Stop.”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-20
    • 2021-06-19
    • 2020-11-16
    • 2018-05-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多