Re: -std=C++11 and strict ANSI compliance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 21 Jan 2020 at 17:15, Anton Shepelev <anton.txt@xxxxxxxxx> wrote:
>
> Hello, all
>
> Shall  -std=C++11 activate strict ANSI compliance by
> means of __STRICT_ANSI__?

Yes. It already does.

> I have found only two op-
> tions in the docs that activate it for C++ -- %-ansi
> and -std=c++98.  Are there other ones?

All -std=c++NN options do.


> I am asking this because in MinGW it does, so  that,
> for  example,  _fileno -- the MS analog of the POSIX
> fileno, is unavailable in stdio.h  with  -std=C++11.
> The  MinGW  maintainers  maintain  an  opinion  that
> -std=C++11 turns on __STRICT_ANSI__, for which  rea-
> son  a  non-standard function shall not be available
> in a standard header in standard C++11 mode,  simply
> because it is not part of the standard but an exten-
> sion.
>
> On the other hand, fileno is available in stdio.h on
> Linux  with  -std=C++11.  Is it a defect, a courtesy
> of the developers, or a requirement for a POSIX OS?

That's because g++ on GNU/Linux also defines _GNU_SOURCE for ALL -std
options (this is in addition to __STRICT_ANSI__ if you used a
-std=c++NN option). Defining _GNU_SOURCE exposes all POSIX functions
and GNU extensions.

I intend to change that one day, so _GNU_SOURCE will never be
automatically defined by the compiler.

> In other words, is the programmer entitled to expect
> fileno  (_fileno) and other POSIX (Microsoft) exten-
> sions in stdio.h while compiling with -std=C++11  on
> a  POSIX  (Microsoft) OS, or is through the mere ne-
> glect or coutesy of the developers that it *happens*
> to be available?

It happens to be available on GNU/Linux. That will change one day.

It is wrong to expect it to be available when compiling with -std=c++11.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux