Subject: _POSIX_C_SOURCE 199309L and when to use _NETBSD_SOURCE?
To: None <current-users@NetBSD.org>
From: Jeremy C. Reed <reed@reedmedia.net>
List: current-users
Date: 12/14/2006 19:45:01
I am trying to compile some code that has
#define _POSIX_C_SOURCE 199309L
This on NetBSD/i386 3.99.24.
Some errors (with my notes prefixed with ***):
/usr/include/unistd.h:321: error: expected declaration specifiers or '...' before 'u_long'
/usr/include/unistd.h:321: error: expected declaration specifiers or '...' before 'u_int'
In file included from ../include/misc.h:143,
from utils.c:83:
/usr/include/stdlib.h:246: error: expected ')' before '*' token
doesn't know "u_char"
In file included from utils.c:102:
/usr/include/signal.h:69: error: expected ')' before 'int'
*** doesn't know ""pthread_t"
In file included from utils.c:107:
/usr/include/sys/wait.h:135: error: duplicate member 'w_Filler'
/usr/include/sys/wait.h:136: error: duplicate member 'w_Retcode'
/usr/include/sys/wait.h:136: error: duplicate member '({anonymous})'
/usr/include/sys/wait.h:137: error: duplicate member 'w_Coredump'
/usr/include/sys/wait.h:137: error: duplicate member '({anonymous})'
/usr/include/sys/wait.h:137: error: duplicate member '({anonymous})'
/usr/include/sys/wait.h:138: error: duplicate member 'w_Termsig'
/usr/include/sys/wait.h:138: error: duplicate member '({anonymous})'
/usr/include/sys/wait.h:138: error: duplicate member '({anonymous})'
/usr/include/sys/wait.h:138: error: duplicate member '({anonymous})'
/usr/include/sys/wait.h:153: error: duplicate member 'w_Filler'
/usr/include/sys/wait.h:154: error: duplicate member 'w_Stopsig'
/usr/include/sys/wait.h:154: error: duplicate member '({anonymous})'
/usr/include/sys/wait.h:155: error: duplicate member 'w_Stopval'
/usr/include/sys/wait.h:155: error: duplicate member '({anonymous})'
/usr/include/sys/wait.h:155: error: duplicate member '({anonymous})'
The problems go away by doing before this:
#define _NETBSD_SOURCE 1
But I don't know if it this is done correctly.
Can someone please explain when and why to use _NETBSD_SOURCE?
I read some about this on /usr/include/sys/featuretest.h.
By the way, I think the same problem is fixed on Solaris with:
#ifdef sun * Needed to tell Solaris headers not to restrict to */
#define __EXTENSIONS__ /* only the functions defined in POSIX 199309. */
#endif
Does that give me any clue?
I assume a simple fix is just:
#ifdef __NetBSD__
#define _NETBSD_SOURCE
#endif
But since I don't understand the ramifications ...
The original code is at
http://gitweb.freedesktop.org/?p=xorg/xserver.git;a=blob;h=9824501e7a183d0909b7a573c6954e6a94c60c9a;hb=9e32bf98bc9ab17a137664d01f59a8f426f7ff3b;f=os/utils.c