Strange include order problems

Discussion in 'C++' started by Zbigniew, May 2, 2007.

  1. Zbigniew

    Zbigniew Guest

    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
     
    Zbigniew, May 2, 2007
    #1
    1. Advertising

  2. Zbigniew

    Zbigniew Guest

    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
     
    Zbigniew, May 2, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Soren Kuula
    Replies:
    2
    Views:
    513
    Soren Kuula
    Feb 1, 2004
  2. Phil
    Replies:
    3
    Views:
    571
    Janwillem Borleffs
    May 27, 2004
  3. Andreas Bogenberger
    Replies:
    3
    Views:
    957
    Andreas Bogenberger
    Feb 22, 2008
  4. cspoh
    Replies:
    0
    Views:
    256
    cspoh
    Jul 31, 2003
  5. Stephan Kämper
    Replies:
    2
    Views:
    245
    Stephan Kämper
    Jan 18, 2004
Loading...

Share This Page