【发布时间】:2017-11-27 05:33:52
【问题描述】:
我将 gcc 4.6.0 用于 armv7。今天我需要编译这个源码:
#include <sys/types.h>
#include <dirent.h>
int main(void)
{
DIR *dir = opendir(".");
if(dir)
{
struct dirent *ent;
while ((ent = readdir(dir)) != NULL)
{
puts(ent->d_name);
}
}
else
{
fprintf(stderr, "Error opening directory\n");
}
return 0;
}
在编译时出现了这样的错误:
test.c:在函数'main'中:test.c:10:31:错误:'NULL'未声明 (在此函数中首次使用)test.c:10:31: 注意:每个未声明 标识符对于它出现的每个函数只报告一次 test.c:17:1:警告:内置的隐式声明不兼容 函数'fprintf' [默认启用] test.c:17:9: error: 'stderr' 未声明(在此函数中首次使用)
我该如何解决这个问题?
【问题讨论】:
标签: gcc