This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problems with default _POSIX_C_SOURCE in features.h ??



On 09/04/2019 16:00, Chris Hall wrote:
> On 09/04/2019 18:42, Adhemerval Zanella wrote:
>> On 09/04/2019 14:12, Chris Hall wrote:
> ...
>>> 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.
> 
>> My understanding is because both __USE_MISC and __USE_GNU are internal flags not meant to be set by external programs and they can be removed/added in future glibc releases.
> 
> I was trying to use "with __USE_GNU" as a short-hand for "the GNU extensions, as enabled by _GNU_SOURCE".
> 
> So, if I specify (say) _XOPEN_SOURCE=600, glibc appears to do its best to give me the facilities which were aligned with that version of the standard -- *without* any GNU extensions.  To enable GNU Extensions as well, I must add -D_GNU_SOURCE, which overrides my -D_XOPEN_SOURCE=600, and (currently) gives me _XOPEN_SOURCE=700.
> 
> Perhaps glibc is prepared to support the selection of an older standard set of features, but is not prepared to figure out which GNU Extensions are "compatible" with that older standard.
> 
> Perhaps it just makes no sense to ask for _XOPEN_SOURCE=600 with GNU Extensions.

As I said, glibc does not provide the sense of version for _GNU_SOURCE, as for
_XOPEN_SOURCE or _POSIX_C_SOURCE.  Currently you can't target a specific version
of glibc using _GNU_SOURCE, said 2.23 or 2.24.

Maybe it might an option in the future to add such facility, it would require
mapping each gnu extension to a particular version and conditionalize them
on each installed header. 

> 
> ...
>> The main problem in my view is there is no guarantee from glibc for which
>> _POSIX_C_SOURCE _DEFAULT_SOURCE will define in the future for possible new
>> _POSIX_C_SOURCE values. I think it is worth a discussion and I will raise
>> this question on libc-alpha.
> 
> My guess is that it will select the latest and greatest.
> 
> Will anyone commit to it setting _POSIX_C_SOURCE=200809L forever ??
> 
> Which leads to the problem that to enable XSI with _DEFAULT_SOURCE, you (currently) have to know which -D_XOPEN_SOURCE=xxx to use, and that depends on which version of the library is being compiled for.

As I said, there was not need to change it from original default of POSIX1.2008,
and I asked on libc-alpha which would be the idea for this flag [1].

[1] https://sourceware.org/ml/libc-alpha/2019-04/msg00239.html


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]