Gcc错误:“NULL”和“stderr”未声明

Gcc错误:“NULL”和“stderr”未声明,gcc,Gcc,我正在为armv7使用GCC4.6.0。今天我需要编译这个源代码: #include <sys/types.h> #include <dirent.h> int main(void) { DIR *dir = opendir("."); if(dir) { struct dirent *ent; while ((ent = readdir(dir)) != NULL) { pu

我正在为armv7使用GCC4.6.0。今天我需要编译这个源代码:

#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”未声明 此函数测试中首次使用。c:10:31:注意:每个未声明 标识符对于它出现在中的每个函数只报告一次 test.c:17:1:警告:内置函数的不兼容隐式声明 函数“fprintf”[默认启用]测试。c:17:9:错误:“stderr” 此函数中未声明的首次使用


如何解决此问题?

添加以下内容:

#include <stdio.h>

谢谢,我有东西准备好了