Mail Archives: djgpp-workers/1998/07/03/13:13:34
I looked at why Linux #defines _POSIX_C_SOURCE for you. On my system
(Debian 1.3.somthing, libc5-based) it's because of the "-D__linux__"
option that is passed as default to gcc as can be seen from "gcc -v
c.c":
/usr/lib/gcc-lib/i486-linux/2.7.2.1/cpp -lang-c -v -undef
-D__GNUC__=2 -D__GNUC_MINOR__=7 -D__ELF__ -Dunix -Di386 -Dlinux
-D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__i386
-D__linux -Asystem(unix) -Asystem(posix) -Acpu(i386) -Amachine(i386)
-D__i486__ c.c /tmp/cca06972.i
[...]
where c.c is as follows:
----- c.c starts. -----
#ifdef _POSIX_C_SOURCE
char pos1[] = "_POSIX_C_SOURCE defined";
#else
char pos1[] = "_POSIX_C_SOURCE not defined";
#endif
#include <stdio.h>
#ifdef _POSIX_C_SOURCE
char pos2[] = "_POSIX_C_SOURCE defined";
#else
char pos2[] = "_POSIX_C_SOURCE not defined";
#endif
----- c.c ends. -----
Examining c.s from "gcc -S c.c" yields:
pos1:
.string "_POSIX_C_SOURCE not defined"
[...]
pos2:
.string "_POSIX_C_SOURCE defined"
Trying with "gcc -U__linux__ -S c.c" yields:
pos1:
.string "_POSIX_C_SOURCE not defined"
[...]
pos2:
.string "_POSIX_C_SOURCE not defined"
So this is a work-around. Does anybody know if the flags above (like
the culprit "-D__linux__") really should really be defined if you
cross-compile?
Pettersson, Symphony No. 2,
MartinS
- Raw text -