You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by Vivian Zhou <vi...@yahoo.com> on 2008/02/20 21:50:36 UTC

Strange compilation error

Hi, All,

I am trying to use AXIS2/c in my c++ application. I am now just encountering some compilation problems. Here is what I do:

(1) I have a c++ visual studo project (Microsoft Visual C++ .NET 2003). I can compile the project and run it without problem.

(2) I create a header file called test.h that include some header files from the AXIS2/c includes like this: 

    #include <axiom_node.h>
    #include <axiom_element.h>
    #include <axiom_namespace.h>    

    #include <axis2_const.h>
    #include <axis2_http_transport.h>
    #include <axutil_env.h>
    #include <axutil_utils.h>
    #include <axutil_utils_defines.h>

I also included some other header files I used in my project and defined a class with some methods, like I do in this project.

(3) I created a c++ source file called test.cpp, which also includes some header files from AXIS2/c and some other header files I used in the project, I implemented the class I defined in the header file test.h (also included in my source file of course).

(4) Now I added the header file test.h and the source file test.cpp into my visual c++ project, and just try to compile this single file, and I got a bunch of compilation errors like the following:
================================================
xform error C2011: 'hostent' : 'struct' type redefinition
        c:\Program Files (x86)\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(153) : see declaration of 'hostent'
xform error C2011: 'linger' : 'struct' type redefinition
        c:\Program Files (x86)\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(540) : see declaration of 'linger'
xform error C2011: 'netent' : 'struct' type redefinition
        c:\Program Files (x86)\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(166) : see declaration of 'netent'
xform error C2011: 'protoent' : 'struct' type redefinition
        c:\Program Files (x86)\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(185) : see declaration of 'protoent'
xform error C2011: 'servent' : 'struct' type redefinition
        c:\Program Files (x86)\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(173) : see declaration of 'servent'
xform error C2011: 'sockaddr' : 'struct' type redefinition
        c:\Program Files (x86)\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(494) : see declaration of 'sockaddr'
xform error C2011: 'sockaddr_in' : 'struct' type redefinition
        c:\Program Files (x86)\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(321) : see declaration of 'sockaddr_in'
===============================================================

It seems that I got some conflicting defnition between the AXIS2/c and other headers envovled in my project.  Also note that WinSock.h was not directly included in my source file test.cpp or the header file test.h.

What is the suggested solution here? I would think this is a very common use senario.

Thanks much in advance.

V.


      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping