www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2012/09/09/13:27:57

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
Message-ID: <504CD18B.1060207@iki.fi>
Date: Sun, 09 Sep 2012 20:27:39 +0300
From: Andris Pavenis <andris DOT pavenis AT iki DOT fi>
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: Invalid tests for __STDC_VERSION__ in DJGPP header files
Reply-To: djgpp-workers AT delorie DOT com

-_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
Some examples:

[andris AT ap ~]$ i586-pc-msdosdjgpp-gcc -dD -E -std=c99 -x c /dev/null | grep STDC 

#define __STDC__ 1
#define __STDC_VERSION__ 199901L
#define __STDC_HOSTED__ 1
#define __GNUC_STDC_INLINE__ 1
[andris AT ap ~]$ i586-pc-msdosdjgpp-gcc -dD -E -std=c90 -x c /dev/null | grep STDC 

#define __STDC__ 1
#define __STDC_HOSTED__ 1
[andris AT ap ~]$ i586-pc-msdosdjgpp-gcc -dD -E -std=c89 -x c /dev/null | grep STDC
#define __STDC__ 1
#define __STDC_HOSTED__ 1
[andris AT ap ~]$ i586-pc-msdosdjgpp-gcc -dD -E -std=c9x -x c /dev/null | grep STDC 

#define __STDC__ 1
#define __STDC_VERSION__ 199901L
#define __STDC_HOSTED__ 1
#define __GNUC_STDC_INLINE__ 1
[andris AT ap ~]$ i586-pc-msdosdjgpp-gcc -dD -E -std=c11 -x c /dev/null | grep STDC
#define __STDC__ 1
#define __STDC_VERSION__ 201112L
#define __STDC_UTF_16__ 1
#define __STDC_UTF_32__ 1
#define __STDC_HOSTED__ 1
#define __GNUC_STDC_INLINE__ 1

As the result tests used in header files like

#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
   || !defined(__STRICT_ANSI__)

are invalid.

I see several possibilities
1) assume that the version is new enough when __STDC_VERSION__ is not defined
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199901L) \
   || !defined(__STRICT_ANSI__)
2) remove tests for version 199001 or later at all (one may need tests for newer
    versions though)
3) require __STDC_VERSION__ to be defined for very old GCC versions (as far as
    I tested gcc-3.4.4 is considered not very old)

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 
is verified to fix the build (only tested cross-native build from Linux)

Andris

- Raw text -


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