EmbDev.net

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


Author: Mike Nacked (Company: Home) (invalid)
Posted on:

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(".");
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?

Author: Jobst Quis (joquis)
Posted on:

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

Reply

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]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig