Strange include order problems

Z

Zbigniew

Hi,

Compiler: GCC 3.3.5
OS: SuSE Linux (Kernel: 2.6.11)

I reorganized my source code and now almost all my header files went
to "Include" folder.
Now when compiling with -I option I have plenty of problems with
system include files:
"conflict with previous declaration"


c++ -c -I../Include AmaSocket.cpp
C++ Libs source compilation AmaSocket.cpp ...
In file included from /usr/include/stdlib.h:43,
from /usr/include/c++/3.3.5/cstdlib:52,
from /usr/include/c++/3.3.5/bits/stl_algobase.h:67,
from /usr/include/c++/3.3.5/memory:54,
from /usr/include/c++/3.3.5/string:48,
from ../Include/AmaStr.h:12,
from ../Include/AmaSocket.h:5,
from AmaSocket.cpp:4:
/usr/include/bits/waitstatus.h:80: error: declaration of `unsigned
int
wait::<anonymous struct>::__w_retcode'
/usr/include/bits/waitstatus.h:75: error: conflicts with previous
declaration `
unsigned int wait::<anonymous struct>::__w_retcode'



When I change
-I"../Include"
option to
-idirafter"../Include"
compilation goes without earlier problems, but up to moment where I
have my own header files named the same as system (i.e. list.h with my
classes working on lists). In this case #include "list.h" acts as I
would include system file, not my own from "../Include"

list.cpp:
#include "list.h" // my own file inside ../Include folder
....

When I specify exactly #include "../Include/AmaSocket.h" without using
"-I../Include" then I do not have any problems with conflicting
declarations.

Any comments?

Thanks in advance
zmk
 
Z

Zbigniew

I'd like to add compiler's output:

c++ -v -c -idirafter../Include -idirafter../appserver/Include
list.cpp
C++ Libs source compilation list.cpp ...
Reading specs from /usr/lib/gcc-lib/i586-suse-linux/3.3.5/specs
Configured with: ../configure --enable-threads=posix --prefix=/usr --
with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/
share/man --enable-languages=c,c++,f77,objc,java,ada --disable-
checking --libdir=/usr/lib --enable-libgcj --with-slibdir=/lib --with-
system-zlib --enable-shared --enable-__cxa_atexit i586-suse-linux
Thread model: posix
gcc version 3.3.5 20050117 (prerelease) (SUSE Linux)
/usr/lib/gcc-lib/i586-suse-linux/3.3.5/cc1plus -quiet -v -D__GNUC__=3
-D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=5 -D_GNU_SOURCE -idirafter../
Include -idirafter../appserver/Include list.cpp -D__GNUG__=3 -quiet -
dumpbase list.cpp -auxbase list -version -o /tmp/ccjHxni4.s
ignoring nonexistent directory "../appserver/Include"
GNU C++ version 3.3.5 20050117 (prerelease) (SUSE Linux) (i586-suse-
linux)
compiled by GNU C version 3.3.5 20050117 (prerelease) (SUSE Linux).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-
heapsize=131072
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/3.3.5
/usr/include/c++/3.3.5/i586-suse-linux
/usr/include/c++/3.3.5/backward
/usr/local/include
/usr/lib/gcc-lib/i586-suse-linux/3.3.5/include
/usr/i586-suse-linux/include
/usr/include
../Include
End of search list.
In file included from /usr/include/c++/3.3.5/backward/list.h:59,
from list.cpp:3:
/usr/include/c++/3.3.5/backward/backward_warning.h:32:2: warning:
#warning This file includes at least one deprecated or antiquated
header. Please consider using one of the 32 headers found in section
17.4.1.2 of the C++ standard. Examples include substituting the <X>
header for the <X.h> header for C++ includes, or <sstream> instead of
the deprecated header <strstream.h>. To disable this warning use -Wno-
deprecated.
list.cpp:19: error: syntax error before `::' token
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top