standards/187378: stdlib.h doesn't define W* macros (e.g. WEXITSTATUS)
brde at optusnet.com.au
Tue Mar 11 17:30:59 UTC 2014
On Tue, 11 Mar 2014, Peter Pentchev wrote:
> > >Description:
> > As per this document:
> > http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html
> > stdlib.h should define W* macros like WEXITSTATUS etc. However, it doesn'=
> FWIW, this is even documented in FreeBSD's stdlib.h :)
> /* XXX XSI requires pollution from <sys/wait.h> here. We'd rather not. */
> Yes, I know this doesn't help you much; I'm just trying to point out
> that, well, this is not an accidental omission, but a deliberate design
> decision. For the reasons for it you'll have to ask the people who did
> it - this particular text seems to have been added by Garrett Wollman
> back in 2002, but I think that he was just documenting the status quo
> rather than making a decision right there and then.
This was a bug in XSI. You can't even use these macros without doing
something nonstandard to get a value that they apply too.
Unfortunately, the infestation has now spread to POSIX itself -- this is
now shaded CX instead of XSI in the above URL.
The infestation has also spread to the nested includes. In the 2001 version:
11720 XSI Inclusion of the <stdlib.h> header may also make visible all symbols from <stddef.h>,
11721 <limits.h>, <math.h>, and <sys/wait.h>.
This is now shaded CX. It bug is still a "may", so is not required.
Applications cannot depend on it, so they must include <sys/wait.h>
for themself if they want to use a function like wait() to get values
that the WEXITSTATUS, etc., macros apply to.
The POSIX CX and XSI markup is much more readable than the ifdefs in
the C source code, even when when it is misrendered by at least text
browsers. It allows a sorted linear list of functions, while the C
source code is grouped to create XSI and BSD sections that become
increasingly unreadable as they grow internal ifdef tangles. The
C ifdefs are inherently more complicated since they need version
numbers for the standards. glibc uses a differently organization
that makes stdlib.h several times larger and more than several times
More information about the freebsd-standards