Archived

This forum has been archived. Please start a new discussion on GitHub.

How can use MFC with ICE???

I create a MFC AppWizard(exe) project. then insert two c++ source files (*.h and *.cpp )that its produce from Slice2cpp.But when i compile this project then appear the follow errors,why???How can use the mfc with ice?
Thank you very much.

errors:
d:\program files\microsoft visual studio\vc98\include\stlport\stl\debug\_debug.h(166) : warning C4005: '_STLP_DEBUG_CHECK' : macro redefinition
d:\program files\microsoft visual studio\vc98\include\stlport\stl\_config.h(356) : see previous definition of '_STLP_DEBUG_CHECK'
d:\program files\microsoft visual studio\vc98\include\stlport\stl\debug\_debug.h(167) : warning C4005: '_STLP_DEBUG_DO' : macro redefinition
d:\program files\microsoft visual studio\vc98\include\stlport\stl\_config.h(357) : see previous definition of '_STLP_DEBUG_DO'
d:\program files\microsoft visual studio\vc98\include\stlport\stl\debug\_vector.h(268) : error C2953: 'vector' : template class has already been defined
d:\program files\microsoft visual studio\vc98\include\stlport\stl\debug\_vector.h(268) : see declaration of 'vector'
..\code\ice-1.2.0\include\ice\config.h(83) : error C2065: 'WSAGetLastError' : undeclared identifier
..\code\ice-1.2.0\include\iceutil\mutex.h(146) : error C2065: 'TryEnterCriticalSection' : undeclared identifier
..\code\ice-1.2.0\include\ice\current.h(74) : error C2079: 'facet' uses undefined class 'vector<class _STL::basic_string<char,class _STL::char_traits<char>,class _STL::allocator<char> >,class _STL::allocator<class _STL::
basic_string<char,class _STL::char_traits<char>,class _STL::allocator<char> > > >'
..\code\ice-1.2.0\include\iceutil\time.h(38) : error C2833: 'operator timeval' is not a recognized operator or type
..\code\ice-1.2.0\include\iceutil\time.h(38) : error C2059: syntax error : 'newline'
..\code\ice-1.2.0\include\iceutil\time.h(38) : error C2238: unexpected token(s) preceding ';'
..\code\ice-1.2.0\include\ice\buffer.h(32) : error C2079: 'b' uses undefined class 'vector<unsigned char,class _STL::allocator<unsigned char> >'
..\code\ice-1.2.0\include\ice\buffer.h(33) : error C2027: use of undefined type 'vector<unsigned char,class _STL::allocator<unsigned char> >'
..\code\ice-1.2.0\include\ice\buffer.h(33) : error C2146: syntax error : missing ';' before identifier 'i'
..\code\ice-1.2.0\include\ice\buffer.h(33) : error C2501: 'iterator' : missing storage-class or type specifiers
..\code\ice-1.2.0\include\ice\buffer.h(33) : error C2501: 'i' : missing storage-class or type specifiers
d:\program files\microsoft visual studio\vc98\include\stlport\stl\debug\_list.h(302) : error C2953: 'list' : template class has already been defined
d:\program files\microsoft visual studio\vc98\include\stlport\stl\debug\_list.h(302) : see declaration of 'list'
d:\program files\microsoft visual studio\vc98\include\stlport\stl\debug\_list.h(325) : error C2995: 'swap' : template function has already been defined
d:\program files\microsoft visual studio\vc98\include\stlport\stl\_list.h(557) : see declaration of 'swap'
..\code\ice-1.2.0\include\ice\basicstream.h(51) : error C2027: use of undefined type 'vector<unsigned char,class _STL::allocator<unsigned char> >'
..\code\ice-1.2.0\include\ice\basicstream.h(51) : error C2061: syntax error : identifier 'size_type'
..\code\ice-1.2.0\include\ice\basicstream.h(73) : error C2027: use of undefined type 'vector<unsigned char,class _STL::allocator<unsigned char> >'
..\code\ice-1.2.0\include\ice\basicstream.h(73) : error C2061: syntax error : identifier 'size_type'
..

Comments

  • bernard
    bernard Jupiter, FL
    Hello,

    Since it is possible to use VC6, STLPort and MFC together (see http://www.codeguru.com/cpp_mfc/vector.html), you can also add Ice to the mix!

    Assuming you have a proper Ice build and build environment (in particular you can build and run the demos successfully), I would suspect an include-order issue.

    From IceUtil/Config.h:
    //
    // For STLport. If we compile in debug mode, we want to use the debug
    // STLport library. This is done by setting _STLP_DEBUG before any
    // STLport header files are included.
    //
    #if !defined(NDEBUG) && !defined(_STLP_DEBUG)
    #   define _STLP_DEBUG
    #endif
    

    You are probably including directly or indirectly a STL header before any Ice header. The easiest solution is to add -D_STLP_DEBUG to your debug project configuration.

    Cheers,
    Bernard
  • hello,
    Thanks for your help,i have added _STLP_DEBUG into my debug project configuration.Some problem have already solution,but also appear these follow error that puzzle me.I hope you can help me to solution it.


    Configuration: MVAPEnterpriseClient - Win32 Debug
    Compiling...
    EnterpriseClient.cpp
    ..\ice-1.2.0\include\ice\config.h(83) : error C2065: 'WSAGetLastError' : undeclared identifier
    ..\ice-1.2.0\include\iceutil\mutex.h(146) : error C2065: 'TryEnterCriticalSection' : undeclared identifier
    ..\ice-1.2.0\include\iceutil\time.h(38) : error C2833: 'operator timeval' is not a recognized operator or type
    ..\ice-1.2.0\include\iceutil\time.h(38) : error C2059: syntax error : 'newline'
    ..\ice-1.2.0\include\iceutil\time.h(38) : error C2238: unexpected token(s) preceding ';'
    D:\MVAP\MVAPEnterpriseClient\EnterpriseClient.cpp(74) : error C2039: 'ice_appendFacet' : is not a member of 'Object'
    ..\ice-1.2.0\include\ice\object.h(49) : see declaration of 'Object'
    D:\MVAP\MVAPEnterpriseClient\EnterpriseClient.cpp(110) : error C2039: 'ice_appendFacet' : is not a member of 'Object'
    ..\ice-1.2.0\include\ice\object.h(49) : see declaration of 'Object'
    D:\MVAP\MVAPEnterpriseClient\EnterpriseClient.cpp(161) : error C2039: 'ice_appendFacet' : is not a member of 'Object'
    ..\ice-1.2.0\include\ice\object.h(49) : see declaration of 'Object'
    D:\MVAP\MVAPEnterpriseClient\EnterpriseClient.cpp(197) : error C2039: 'ice_appendFacet' : is not a member of 'Object'
    ..\ice-1.2.0\include\ice\object.h(49) : see declaration of 'Object'
    D:\MVAP\MVAPEnterpriseClient\EnterpriseClient.cpp(248) : error C2039: 'ice_appendFacet' : is not a member of 'Object'
    ..\ice-1.2.0\include\ice\object.h(49) : see declaration of 'Object'
    D:\MVAP\MVAPEnterpriseClient\EnterpriseClient.cpp(284) : error C2039: 'ice_appendFacet' : is not a member of 'Object'
    ..\ice-1.2.0\include\ice\object.h(49) : see declaration of 'Object'
    D:\MVAP\MVAPEnterpriseClient\EnterpriseClient.cpp(1161) : error C2440: 'type cast' : cannot convert from 'class MVAPEnterpriseClient::LoginMng *' to 'class IceInternal::Handle<class Ice::Object>'
    No constructor could take the source type, or constructor overload resolution was ambiguous
    D:\MVAP\MVAPEnterpriseClient\EnterpriseClient.cpp(1167) : error C2440: 'type cast' : cannot convert from 'class MVAPEnterpriseClient::LoginMng *' to 'class IceInternal::Handle<class Ice::Object>'
    No constructor could take the source type, or constructor overload resolution was ambiguous
    D:\MVAP\MVAPEnterpriseClient\EnterpriseClient.cpp(1251) : error C2440: 'type cast' : cannot convert from 'class MVAPEnterpriseClient::SMMng *' to 'class IceInternal::Handle<class Ice::Object>'
    No constructor could take the source type, or constructor overload resolution was ambiguous
    D:\MVAP\MVAPEnterpriseClient\EnterpriseClient.cpp(1257) : error C2440: 'type cast' : cannot convert from 'class MVAPEnterpriseClient::SMMng *' to 'class IceInternal::Handle<class Ice::Object>'
    No constructor could take the source type, or constructor overload resolution was ambiguous
    D:\MVAP\MVAPEnterpriseClient\EnterpriseClient.cpp(1430) : error C2440: 'type cast' : cannot convert from 'class MVAPEnterpriseClient::AddressBook *' to 'class IceInternal::Handle<class Ice::Object>'
    No constructor could take the source type, or constructor overload resolution was ambiguous
    D:\MVAP\MVAPEnterpriseClient\EnterpriseClient.cpp(1436) : error C2440: 'type cast' : cannot convert from 'class MVAPEnterpriseClient::AddressBook *' to 'class IceInternal::Handle<class Ice::Object>'
    No constructor could take the source type, or constructor overload resolution was ambiguous
    Error executing cl.exe.

    MVAPEnterpriseClient.exe - 17 error(s), 0 warning(s)
  • bernard
    bernard Jupiter, FL
    Hello,

    This looks like more include ordering problems. For example you get
    ..\ice-1.2.0\include\iceutil\mutex.h(146) : error C2065: 'TryEnterCriticalSection' : undeclared identifier
    
    because you include <windows.h> before IceUtil/Config.h, which defines
    the _WIN32_WINNT macro as 0x0400 before including <windows.h>.

    If you could post your project (or a small version of your project), we will be able to find the remaining problems!

    Cheers,
    Bernard
  • Hello,
    Thank you very much for your help.I also have some problem can not solute .That is my a simply project, i compile it under vc6.0.

    thanks!
  • bernard
    bernard Jupiter, FL
    Hi Alesio,

    I was able to build your demo by applying the following modifications:
    * In Project settings Category: Precompiled Headers, I selected "Not using precompiled headers"
    * I removed #include "stdafx.h" from EnterpriseClient.cpp; in general, you should never modify code generated by slice2cpp.
    * I added IceD.lib IceUtilD.lib and stlport_vc6_stldebug.lib as extra libraries.

    Cheers,
    Bernard
  • Hello bernard,
    you are very kind.Thank you very much,i am very happy,my project can be build with your help.