Web lists-archives.com

Re: [Mingw-users] _XOPEN_SOURCE




On 4/21/2017 11:32 AM, Keith Marshall wrote:
> On 21/04/17 15:12, Earnie wrote:
>> On 4/20/2017 11:32 AM, Bryan Henderson wrote:
>>> Keith Marshall, in a recent thread:
>>>>  in _every_ case, the application is _required_ to specify the 
>>>>  _XOPEN_SOURCE value for which conformance is desired.
>>>
>>> Why do you say that?  Common sense, or did you see it written
>>> somewhere?
>>>
>>> And what do you make of the fact that every other X/Open-capable
>>> C library explicitly recognizes _XOPEN_SOURCE = null string as
>>> meaning "source code expects C library to conform to the original
>>> X/Open standard?
> 
>> This reference [1] supports Bryan's assertion.
> 
>> [1] http://man7.org/linux/man-pages/man7/feature_test_macros.7.html
> 
> Yet, the example it cites requires a definition _with_ a value, (and 
> moreover, a non-zero value); when preceded by:
> 
> #define _XOPEN_SOURCE  /* no value */
> 
> GCC will complain:
> 
> bar.c:2:19: error: operator '&&' has no left operand
>  #if _XOPEN_SOURCE && _XOPEN_SOURCE < 500
>                    ^

So that documentation is somewhat off as defining _XOPEN_SOURCE without
a value could never be tested that way without an issue.  However, here
is another reference [2] indicating that _XOPEN_SOURCE may be defined
without a value prior to version 500.

This reference [3] indicates that _XOPEN_SOURCE should contain a value.
So prior to SUSv3 it appears to be up in the air as to how the constant
should be used; with versus without a value.

Given that GCC itself doesn't manage without a value I would suggest
that the correct fix is to assign a value.  The user will get further
with defining a value since there appears to be precedence for such
definition from the compiler authors.

[2] http://docs.oracle.com/cd/E19253-01/816-5175/standards-5/index.html
[3]
https://books.google.com/books?id=2SAQAQAAQBAJ&pg=PA62&lpg=PA62&dq=_XOPEN_SOURCE+prior+to+500&source=bl&ots=qQy-d8DBqz&sig=hJPPWeiUeH0uL4qLqXgyF2pwTQ8&hl=en&sa=X&ved=0ahUKEwiGsvSN1rbTAhWBbSYKHVL3AXUQ6AEIPjAE#v=onepage&q=_XOPEN_SOURCE%20prior%20to%20500&f=false

-- 
Earnie

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe