On Friday 06 October 2006 09:31, Arturo 'Buanzo' Busleiman wrote:
> gcc -o digits -Wall -ansi -pedantic digits.c
>
> With that, I got the "implicit declaration of function BLAH" message. When
> that happens, and the man page does not list anything special, I usually
> add this at the beginning of the source file:
>
> #define _GNU_SOURCE
>
> et voila', now compiles cleanly
Yes but this is still entirely wrong....  Come on people let's at least try to 
be standards based.

If you really want isascii() and isblank() then you need this 
#define _XOPEN_SOURCE 600

Without the above define:
gcc -Wall -pedantic ctype.c -o ctype
ctype.c: In function 'main':
ctype.c:13: warning: implicit declaration of function 'isascii'
ctype.c:14: warning: implicit declaration of function 'isblank'

With the above define:
gcc -Wall -pedantic ctype.c -o ctype

This is needed for "A Strictly Conforming POSIX Application."  If you read the 
SUSv3 it states that you should define _POSIX_C_SOURCE to 200112L, but that 
this is redundant if you define _XOPEN_SOURCE to 600.  Now realistically you 
should not be defining it yourself, you should be testing for compliance then 
using what is available.

Please let's not try and make code completely unportable to different 
compilers just cause we all like gcc.  There may be a day that another 
compiler comes along that is way better than gcc and by using _GNU_SOURCE you 
are locked in.

We do have standards.  They are sometimes a little hard to read and sometimes 
you just can't get the behavior you want by following them, try to use them 
when possible and be aware of the standards that functions are defined in on 
their man pages.
-- 
Zac Slade
[EMAIL PROTECTED]
ICQ:1415282 YM:krakrjak AIM:ttyp99
-- 
gentoo-user@gentoo.org mailing list

Reply via email to