g++ doesn't accept AIX include file
Villumsen, Ole Vedel
olvil@wmdata.com
Thu Dec 9 03:59:00 GMT 1999
Hi!
g++ (incorrectly, I believe) reports an error in /usr/include/sys/m_types.h
on AIX 4.2.1 unless _ALL_SOURCE is defined. I've boiled the problem down to
the following example. The portion of /usr/include/sys/m_types.h that causes
the problem, is quoted in the end.
I read Bjarne Stroustrup: The C++ Programming Language, Second Edition,
section r.7.1.3 The typedef Specifier. It says among other things:
"An unnamed class defined in a typedef gets its typedef name as its name.
For example,
typedef struct { (* ... */ } S; // the struct is named S"
I take this to mean that the above declaration is equivalent to
typedef struct S { (* ... */ } S;
However, in my example, g++ doesn't treat the two forms identically. It
accepts the latter form but reports the former as conflicting.
Command line and output from it:
$ g++ -v --save-temps s4.cpp
Reading specs from /usr/local/lib/gcc-lib/powerpc-ibm-aix4.2.1.0/2.8.1/specs
gcc version 2.8.1
/usr/local/lib/gcc-lib/powerpc-ibm-aix4.2.1.0/2.8.1/cpp -lang-c++ -v -undef
-D_
_GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=8 -D_IBMR2 -D_POWER
-D_AIX
-D_AIX32 -D_AIX41 -D_IBMR2 -D_POWER -D_AIX -D_AIX32 -D_AIX41 -Asystem(unix)
-As
ystem(aix) -D__EXCEPTIONS -D__CHAR_UNSIGNED__ -D_ARCH_COM s4.cpp s4.ii
GNU CPP version 2.8.1
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include/g++
/usr/local/include
/usr/local/powerpc-ibm-aix4.2.1.0/include
/usr/local/lib/gcc-lib/powerpc-ibm-aix4.2.1.0/2.8.1/include
/usr/include
End of search list.
/usr/local/lib/gcc-lib/powerpc-ibm-aix4.2.1.0/2.8.1/cc1plus s4.ii -quiet
-dumpb
ase s4.cc -version -o s4.s
GNU C++ version 2.8.1 (powerpc-ibm-aix4.2.1.0) compiled by GNU C version
2.8.1.
s4.cpp:6: conflicting types for `typedef struct A A'
s4.cpp:5: previous declaration as `struct A'
Contents of s4.ii (uncompressed since it's so small):
# 1 "s4.cpp"
struct A * p1;
typedef struct { int i; } A;
struct B * p2;
typedef struct B { int j; } B;
By the way, I get the same result with gcc version 2.95.2 running on a
alpha-dec-osf4.0d.
Yours,
Ole
As I promised, the relevant portion of the offending
/usr/include/sys/m_types.h file that lead me to the problem:
typedef struct
#ifdef _ALL_SOURCE
label_t
#endif /* _ALL_SOURCE */
{ /* kernel jump buffer */
#ifdef _ALL_SOURCE
struct label_t *prev; /* chain to previous */
ulong_t iar; /* resume address */
ulong_t stack; /* stack pointer */
ulong_t toc; /* toc pointer */
ulong_t cr; /* non-volatile part of cr */
ulong_t intpri; /* priority level of the process */
ulong_t reg[19]; /* non-volatile regs (13..31) */
#else /* _ALL_SOURCE */
struct label_t *__prev; /* chain to previous */
ulong_t __iar; /* resume address */
ulong_t __stack; /* stack pointer */
ulong_t __toc; /* toc pointer */
ulong_t __cr; /* non-volatile part of cr */
ulong_t __intpri; /* priority level of the process */
ulong_t __reg[19]; /* non-volatile regs (13..31) */
#endif /* _ALL_SOURCE */
} label_t;
________________________________________
Ole V. Villumsen
WM-data A/S
Hermodsvej 22
DK-8230 ÃÂ
byhøj
Denmark
Telephone direct: +45 87 44 45 26, home: +45 86 27 29 26
Fax: +45 87 44 44 87
mailto:olvil@wmdata.com
http://www.wmdata.dk
More information about the Gcc-bugs
mailing list