GCC unable to find "errno" when compiling on Ubuntu
Greetings All,
I am trying to compile a very simple program which uses errno variable, but I am getting compile error of not finding "errno" Given is my program.
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <fcntl.h>
4 #include <error.h>
5 #include <string.h>
6
7 int main()
8 {
9 char data[256];
10 int fd;
11
12 if ( (fd = open("/dev/scull0", O_RDONLY)) == -1 )
13 {
14 printf("\nUnable to open driver file - Error <%s>\n", strerror(errno));
15 return 0;
16 }
17
18 while ( read(fd, data, (sizeof(char)*5)) )
19 {
20 printf("\nDriver Data = <%s>", data);
21 }
22
23 close(fd);
24 return 0;
25 }
~
When compiling I am getting the following error.
$ gcc -Wall player.c -o player
player.c: In function ‘main’:
player.c:14: error: ‘errno’ undeclared (first use in this function)
player.c:14: error: (Each undeclared identifier is reported only once
player.c:14: error: for each function it appears in.)
My compiler is
gcc 4.4.3
It appears to me my GCC is pointing to wrong system includes. Any thoughts ?
Regards.
|