This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Problems with default _POSIX_C_SOURCE in features.h ??
- From: Chris Hall <glibc at gmch dot uk>
- To: libc-help at sourceware dot org
- Date: Tue, 9 Apr 2019 18:12:25 +0100
- Subject: Re: Problems with default _POSIX_C_SOURCE in features.h ??
- References: <e96dbe90-b126-aef9-5b51-898901ed673d@gmch.uk> <bc96cf18-5370-67e5-9c67-332176954c6f@linaro.org> <4778eb67-8786-ff0d-a0bc-0db1141d48f4@gmch.uk> <978ca1e9-f4fc-78b5-bae2-22b19b9df194@linaro.org> <c5033de6-b09a-02ac-c53a-db5d257634c4@gmch.uk> <038ad65a-09db-c727-1496-ed6d17944897@linaro.org>
On 09/04/2019 14:09, Adhemerval Zanella wrote:
On 01/04/2019 07:11, Chris Hall wrote:
On 29/03/2019 17:54, Adhemerval Zanella wrote:
...
My understanding is _POSIX_C_SOURCE and _XOPEN_SOURCE are tests are
orthogonal and it will enable the most recent features you enable.
The -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 will set to higher
standard you set, which is _POSIX_C_SOURCE=200809L from
_DEFAULT_SOURCE.
...
Now, I am not sure which would be best course of action on glibc for such
unspecified combinations. Current practice is to follow your description to
conditionality older XSI extension if where the case.
I think we are agreed that _POSIX_C_SOURCE and _XOPEN_SOURCE are not
orthogonal.
...
So my understanding is glibc is not promoting the -D_DEFAULT_SOURCE
-D_XOPEN_SOURCE=600 to _XOPEN_SOURCE=700 and it is indeed behaving
as the manual states which is only setting -D_POSIX_C_SOURCE=200809L.
I think we are agreed that -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 select
an undefined combination of _POSIX_C_SOURCE and _XOPEN_SOURCE.
Setting "the 2008 edition of POSIX" is indeed what the manual says.
So asking for -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 is to ask for
something which is undefined.
However, glibc goes to some effort to support the selection of older
_POSIX_C_SOURCE and/or _XOPEN_SOURCE. But *not* with __USE_MISC and
*not* with __USE_GNU. I have failed to discover why that is -- though
that is probably because I am too stupid.
...
Except that _DEFAULT_SOURCE is (apparently) the only way of
turning on __USE_MISC.
The _GNU_SOURCE, which also defines _DEFAULT_SOURCE, also
defines __USE_MISC.
True. But I don't want GNU extensions -- so I was ignoring that. I
apologise for not being precise.
...
Perhaps:
1. _DEFAULT_SOURCE is intended to exclude XSI altogether.
...
That's not the idea, _DEFAULT_SOURCE does not *include* the
XSI extension but also does not *exclude* them. It is still
possible to include the XSI extension if is is the intention.
OK, so ...
2. _DEFAULT_SOURCE is intended to not include XSI, but
_XOPEN_SOURCE may be used to add same.
The documentation does not rule this out.
... -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 is an expected/supported
combination (currently).
Mind you, when _POSIX_C_SOURCE=202101 (say) arrives and _DEFAULT_SOURCE
selects it, -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=700 will then be an
undefined/unsupported combination :-(
So, to correctly select XSI with _DEFAULT_SOURCE, I have to work on my
configure script, to check (a) what version of _POSIX_C_SOURCE will be
selected by _DEFAULT_SOURCE, and (b) what -D_XOPEN_SOURCE=??? is
required to (correctly) enable XSI. Hurrah !
If _XOPEN_SOURCE is defined, I would force it to 700,
to also be consistent with _GNU_SOURCE and be unambiguous.
Again, I do not think it would be safer or yield much gains to
force either _DEFAULT_SOURCE or _POSIX_C_SOURCE=200809L to set
_XOPEN_SOURCE to 700. Since it is undefined by standard and
has been defined by glibc, it will most likely crate
incompatibilities if we change it and it is not easy to
create a compatibility layer for such cases.
Sorry, I don't understand this.
My point is: if I ask for XSI, by -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=xxx,
I think it would be helpful if _DEFAULT_SOURCE selected the latest and
greatest _XOPEN_SOURCE, to go with the latest and greatest
_POSIX_C_SOURCE which _DEFAULT_SOURCE is also selecting...
...so that, when _POSIX_C_SOURCE=202101 (say) arrives, _DEFAULT_SOURCE
would then set the corresponding _XOPEN_SOURCE=800.
I agree that anybody currently asking for (say) -D_DEFAULT_SOURCE
-D_XOPEN_SOURCE=600 might be surprised by the new result. Though I
think we are agreed that what they currently get is undefined :-(
Chris