www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2012/09/11/09:16:47

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
Message-ID: <504F3374.3080400@iki.fi>
Date: Tue, 11 Sep 2012 15:49:56 +0300
From: Andris Pavenis <andris DOT pavenis AT iki DOT fi>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
CC: =?ISO-8859-1?Q?Martin_Str=F6mberg?= <ams AT ludd DOT ltu DOT se>
Subject: Re: Invalid tests for __STDC_VERSION__ in DJGPP header files
References: <201209111230 DOT q8BCU0rl001296 AT dexter DOT ludd DOT ltu DOT se>
In-Reply-To: <201209111230.q8BCU0rl001296@dexter.ludd.ltu.se>
Reply-To: djgpp-workers AT delorie DOT com

On 09/11/2012 03:30 PM, Martin Strömberg wrote:
> According to Andris Pavenis:
>> -_STDC_VERSION__ is not defined in many cases any recent GCC version. It is only seems to be
>> defined in several cases depending on the command line parameter -std and for C language only
> ...
>> As the result tests used in header files like
>>
>> #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
>>     || !defined(__STRICT_ANSI__)
>>
>> are invalid.
> Those tests aren't invalid. They are checking for __STDC_VERSION__ >=
> 199901L and not __STRICT_ANSI__.
>
> It's possible that old gcc was lying and claiming conformance where it
> wasn't.
>
> ...
>
>> Use of the broken test for __STDC_VERSION__ prevents libstdc++-v3 (GCC-4.8.0 development versions
>> from some last weeks) building OK due to actual contents of stdint.h being compiled out. Variant 1
> That seems to say that libstdc++-v3 requires standard comliance in the
> compiler. How about adding -std=c89/c99/whatever to libstdc++-v3's
> compile options?
>
>
> On the other hand I'm not sure I understand the problem properly so
> perhaps I'm totally wrong.
>
>
According to C standard drafts I have predefined macro __STDC_VERSION__ 
seems to mandatory.
It is however not defined in many cases by GCC as far as I have tested. 
I do not know what would
be best way how to handle that for C

At least for C++ in last standard draft I have (I have not bought 
released version document) in 16.8 is written

2 The following macro names are conditionally defined by the implementation:
_ _ STDC _ _
Whether _ _ STDC _ _ is predefined and if so, what its value is, are 
implementation-defined.
_ _ STDC_MB_MIGHT_NEQ_WC _ _
The integer constant 1, intended to indicate that, in the encoding for 
wchar_t, a member of the basic
character set need not have a code value equal to its value when used as 
the lone character in an
ordinary character literal.
_ _ STDC_VERSION _ _
Whether _ _ STDC_VERSION _ _ is predefined and if so, what its value is, 
are implementation-defined.
_ _ STDC_ISO_10646 _ _
An integer constant of the form yyyymmL (for example, 199712L). If this 
symbol is defined, then every
character in the Unicode required set, when stored in an object of type 
wchar_t, has the same value
as the short identifier of that character. The Unicode required set 
consists of all the characters that
are defined by ISO/IEC 10646, along with all amendments and technical 
corrigenda as of the specified
year and month.

That means that __STDC_VERSION__ is not required to be predefined for 
C++ (if the draft is OK).
As the result I think we should include  '|| defined(__cplusplus)' in 
the condition

I'll check whether it fixes libstdc++ build problem in gcc-4.8.0 
development versions later

Andris



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019