On Sun, 02 May 2004, James Yonan wrote:

> You didn't bracket it with #ifdef TARGET_LINUX -- does that mean it's
> appropriate on all platforms?

> What about this (from the glibc manual): "If your program defines _BSD_SOURCE,
> you must give the option `-lbsd-compat' to the compiler or linker when linking
> the program, to tell it to find functions in this special compatibility
> library before looking for them in the normal C library."

Ouch, that one hurt, so _BSD_SOURCE doesn't look right.

I see this deserves revision and explanation - and maybe no code change
at all.

I came across this compiling with -std=c99 and -pedantic in CFLAGS:

../tun.c: In function `open_tun':
../tun.c:836: error: storage size of 'ifr' isn't known
../tun.c:902: error: `IFNAMSIZ' undeclared (first use in this function)
../tun.c:902: error: (Each undeclared identifier is reported only once
../tun.c:902: error: for each function it appears in.)
../tun.c:921: error: storage size of 'netifr' isn't known
make[1]: *** [tun.o] Error 1
make: *** [all] Error 2

These compiler flags (and similar except the -std=gnuXX) prevent the
definition of __USE_MISC in <features.h>, hence IFNAMSIZ and struct ifr
aren't defined. gcc -std=gnu99 is fine.

/One/ way to define these symbol and struct them is to use _BSD_SOURCE,
but I wasn't aware of the glibc "override POSIX with BSD, require
-lbsd-compat" behaviour, so it make more sense to use _GNU_SOURCE (or
_SVID_SOURCE) instead.

HTH,

-- 
Matthias Andree

Encrypted mail welcome: my GnuPG key ID is 0x052E7D95

Reply via email to