X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f X-Recipient: djgpp-workers AT delorie DOT com Message-ID: <504F6729.5000505@iki.fi> Date: Tue, 11 Sep 2012 19:30:33 +0300 From: Andris Pavenis User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120828 Thunderbird/15.0 MIME-Version: 1.0 To: djgpp-workers AT delorie DOT com Subject: Re: Invalid tests for __STDC_VERSION__ in DJGPP header files References: <201209111230 DOT q8BCU0rl001296 AT dexter DOT ludd DOT ltu DOT se> <504F3374 DOT 3080400 AT iki DOT fi> In-Reply-To: <504F3374.3080400@iki.fi> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from Quoted-Printable to 8bit by delorie.com id q8BGUfS3009476 Reply-To: djgpp-workers AT delorie DOT com On 09/11/2012 03:49 PM, Andris Pavenis wrote: > 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 > Tried --- stdint.h.orig 2012-09-09 19:12:59.000000000 +0300 +++ stdint.h 2012-09-11 19:19:56.936112793 +0300 @@ -9,7 +9,7 @@ #endif #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \ - || !defined(__STRICT_ANSI__) + || !defined(__STRICT_ANSI__) || defined(__cplusplus) typedef signed char int_least8_t; typedef unsigned char uint_least8_t; Fixes libstdc++ build problems for gcc-4.8.0 20120909 (again cross-native build as after removing libstdc++-v3 build directory 'make -j12' on Intel 3930K rebuilds it under Linux in less than 30 seconds) The same should be done for other header files which has similar checks. Does it look OK? Andris