Date: Wed, 12 Mar 2014 04:30:55 +1100 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Peter Pentchev <roam@ringlet.net> Cc: freebsd-standards@freebsd.org Subject: Re: standards/187378: stdlib.h doesn't define W* macros (e.g. WEXITSTATUS) Message-ID: <20140312035904.L898@besplex.bde.org> In-Reply-To: <201403111640.s2BGe1J9031029@freefall.freebsd.org> References: <201403111640.s2BGe1J9031029@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 11 Mar 2014, Peter Pentchev wrote: > > >Description: > > As per this document: > >=20 > > http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/stdlib.h.html > >=20 > > stdlib.h should define W* macros like WEXITSTATUS etc. However, it doesn'= > t. > > 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 unreadable. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140312035904.L898>