This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Detecting whether gcc supports complex types
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: vogt at linux dot vnet dot ibm dot com, gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 12 Nov 2014 16:34:05 +0000
- Subject: Re: Detecting whether gcc supports complex types
- Authentication-results: sourceware.org; auth=none
- References: <20141112134151 dot GA29100 at linux dot vnet dot ibm dot com>
On 12 November 2014 13:41, Dominik Vogt wrote:
> However, this does not work with a plain gcc call, i.e. gcc does
> not define __STDC_VERSION__ (or __STDC__) if not told explicitly
> which standard to use, e.g. with --std=c99.
That's not quite accurate - you can tell gcc to explicitly use
-std=c90 and it doesn't define it, or you can use current trunk with
no -std option and it defines it (because trunk defaults to C11).
GCC does not define __STDC_VERSION__ unless compiling C99 or later,
because (I believe) that's when the macro was first defined.
So it's nothing to do with an explicit -std option, it's to do with
the language version being used, implicitly or explicitly.
But to answer your question, any non-prehistoric version of GCC
supports _Complex even in C90/GNU90 mode, unless -Werror=pedantic (the
option formerly knows as -pedantic-errors) is in use. So if you want
to know that GCC supports _Complex and won't give a diagnostic for its
use, __STDC_VERSION__ seems like the right option.