C++ vs. AIX -ansi

Mark Mitchell mark@codesourcery.com
Mon Feb 5 22:21:00 GMT 2001


On AIX, `g++ -ansi' doesn't work very well depending on the order in
which you #include things.

Consider:

  #include <stdio.h>
  #include <fstream.h>

This issues tons of errors.

The problem is that `g++ -ansi' turns on -D _ANSI_SOURCE.  So, when we
include stdio.h, we include <standards.h>, and everything gets set up
to use a pretty minimal set of stuff.  But, later, when we include
<fstream.h>, we pull in libstdc++-v3/config/os/aix/os_defines.h which
does:

  #ifndef _ALL_SOURCE
  #define _ALL_SOURCE
  #endif

However, the various other defines *implied* by _ALL_SOURCE are not
defined (since <standards.h> has already been defined), so we end up
with a set of macros defined which is inconsistent from the point of
view of the AIX headers.

This is something of a problem.  V3 doesn't work on lots of systems
unless you turn on lots of stuff that isn't on by default.  But you
don't get a chance to turn on until it's potentially "too late".

There are a few obvious options:

  - Punt on g++ -ansi on AIX.

    The problem here is that the testsuite uses -ansi by default, so
    we get some spurious failures.

  - Don't define _ANSI_SOURCE on AIX.  (Can we do this in C++, but
    not C?  If we can, do we want to?)

  - Define all the stuff that <standards.h> would define in
    os_defines.h.  (That's not fully correct since the order of
    include files then influences what you see in the headers.)

Thoughts?

For now, I'm just going to modify the tests in the testsuite so we can
see fewer failures on AIX.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com


More information about the Libstdc++ mailing list