On 2017-12-25 16:43, Ken Brown wrote:
I was under the impression that 'g++ -std=gnu++11' would enable GNU
extensions, but that doesn't seem to be the case. Here's a test on Cygwin:
$ cat temp.cc
#include <stdlib.h>
$ g++ -std=gnu++11 -E -dD temp.cc | grep GNU_VISIBLE
#define __GNU_VISIBLE 0
It seems that I have to explicitly define _GNU_SOURCE, even though I've
used -std=gnu++11:
$ g++ -std=gnu++11 -D_GNU_SOURCE -E -dD temp.cc | grep GNU_VISIBLE
#define __GNU_VISIBLE 1
Is this a bug, or am I misunderstanding '-std=gnu++11'?
Neither gcc -std=gnu* nor g++ -std=gnu++* enable GNU extensions. What
they do is specify that strict ANSI C/C++ should *not* be used (iow
__STRICT_ANSI__ should not be defined, as it is with -std=c* or
-std=c++*). With no other FTMs defined, that would expose POSIX-1.2008
plus BSD and SVr4 extensions, but not XSI or GNU extensions.
However, do note that G++ defines _GNU_SOURCE unconditionally for glibc
(and uclibc) based targets[1] That means that -std=c++* does not work
as documented on those targets, and therefore some C++ packages which
build thereon will not build OOTB on Cygwin. One day I hope to fix this
for them too, at which point C++ authors are will be forced to start
paying attention to FTMs again.