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

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

Rate this post
0 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(".");
struct dirent *ent;
while((ent = readdir(dir)) != NULL)
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
0 useful
not useful
#include <stdio.h>


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.