Detecting whether gcc supports complex types
Jonathan Wakely
jwakely.gcc@gmail.com
Wed Nov 12 16:34:00 GMT 2014
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.
More information about the Gcc-help
mailing list