compiling problem?
i have this example.
#include <unistd.h> int main() { usleep(1000); return 0; } that compiles fine with gcc -Wall test.c -o test but with: gcc -c -Wall -O2 -g -O2 -ansi -I/usr/X11R6/include -I/usr/include/freetype2 -I/usr/include/freetype2/config -I/usr/X11R6/include -I/usr/X11R6/include -I/usr/include/gtk-2.0 -I/usr/include `pkg-config gtk+-2.0 --cflags --libs` test.c I get test.c:4: warning: implicit declaration of function ‘usleep’ and no warning eliminating -ansi so do I have any danger ignoring the warning or shall I skipp -ansi? |
> and no warning eliminating -ansi
is usleep standard? |
I guess not.
from man 3 usleep SYNOPSIS /* BSD version */ #include <unistd.h> void usleep(unsigned long usec); /* SUSv2 version */ #define _XOPEN_SOURCE 500 #include <unistd.h> int usleep(useconds_t usec); |
maybe I should use nanosleep instead from time.h
|
sorry I saw now in the man page: This function is obsolete. Use nanosleep(2) or setitimer(2) instead.
so I go for nanosleep. |
Just a caution - the use of 'test' as a name for the compiled program conflicts with bash.
Also you can use -Wall in g++ |
Quote:
i would also agree that -Wall is a good habit to get into |
ok I shall use another name then test in the future even if I have a absolute path. One day I will not an get in to trouble.
Thanks. |
All times are GMT -5. The time now is 01:15 AM. |