Wednesday, June 15, 2011

Why does the language version being used affect standard semantics?

knoppix@Microknoppix:/tmp$ cat x.c
#include <signal.h>

siginfo_t info;

knoppix@Microknoppix:/tmp$ gcc x.c -c
knoppix@Microknoppix:/tmp$ gcc x.c -c -std=c99
x.c:3: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'info'
knoppix@Microknoppix:/tmp$ 

Hmpf.

2 Comments:

Anonymous Anonymous said...

It doesn't. siginfo is a POSIX feature, so you should be compiling with -DPOSIX_C_SOURCE=200112L (or similar). GCC enables POSIX features by default, as they're generally useful. Asking for strict C99 compliance will disable GCC's auto-enabling of POSIX extensions.

10:16 p.m., June 16, 2011  
Blogger Simon said...

Ah, OK.

Although -DPOSIX_C_SOURCE=200112L doesn't work (with --std=c99). Nor does -D__USE_POSIX, or -D__USE_POSIX199309.

Or -D_POSIX_C_SOURCE=2 or -D_XOPEN_SOURCE or -D_POSIX_SOURCE.

I'll just use -std=gnu99. :-/

5:18 p.m., June 19, 2011  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home