EmbDev.net

Forum: ARM programming with GCC/GNU tools error: 'NULL' and 'stderr' undeclared


von Mike N. (Company: Home) (invalid)


Rate this post
useful
not useful
I'm using gcc 4.6.0 for armv7. Today I needed to compile this source:
#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;
}

At compilation there were here such errors:
test.c: In function 'main':
test.c:10:31: error: 'NULL' undeclared (first use in this function)
test.c:10:31: note: each undeclared identifier is reported only once for 
each function it appears in
test.c:17:1: warning: incompatible implicit declaration of built-in 
function 'fprintf' [enabled by default]
test.c:17:9: error: 'stderr' undeclared (first use in this function)

What am I doing wrong?

von Jobst Q. (joquis)


Rate this post
useful
not useful
#include <stdio.h>

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.