Web lists-archives.com

Re: Why does -std=c++11 hide certain function calls

On Thu, Sep 6, 2018 at 2:45 AM, John Selbie <jselbie@xxxxxxxxx> wrote:
>> For Unixy builds, just don't specify -std. Only specify -std if you want
> to ensure that builds will work with earlier standards, compilers, or
> libraries, or for -std=c* without any special language or library features,
> in which case you may also want to add -pedantic or more restrictive
> options.
> Ahhhh…. that was my mistake.  I had erroneously assumed that not specifying
> -std would result in the oldest version of C++.  A quick check:
>     $ g++ foo.cpp -c -dM -E  | grep cplus
>     #define __cplusplus 201402L
> I was compiling with C++ 14 the whole time.  And it appears that when -std
> is used, the GNU defines are taken out, which ultimately influence how
> POSIX_VISIBLE Is defined within <features.h>.

By default GCC uses a -std=gnu++NN, not -std=c++NN. So you are getting
mostly the latest C++ but it is GNU's flavor with non-standard things
like Variable Length Arrays (VLA's).

> I'm not sure if I agree that -std should hide the functions from unix
> headers. (tldr: unix headers are explicitly outside the c++ standard, so
> the moment they are included, you might as well assume the developer wants
> it all...)

Cygwin and Newlib conflate options in unexpected ways.

I think they are making incorrect leaps about options. For example if
you want Posix you may not want a GCC extension like VLA's. I doubt it
will change, though. You just have to work around it.


Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple