简体   繁体   中英

VS2005 C++ compiler problem including <comdef.h> in MFC application

I am having some trouble converting an old project from VS6 to VS2005. At one place in the code it uses the type variant_t so it includes comdef.h for this purpose. comdef.h then includes comutil.h which generates these errors for me:

c:\program files\microsoft visual studio 8\vc\include\comutil.h(978) : error C2535: '_variant_t::_variant_t(int) throw()' : member function already defined or declared
    c:\program files\microsoft visual studio 8\vc\include\comutil.h(970) : see declaration of '_variant_t::_variant_t'
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1007) : error C2535: '_variant_t::operator int(void) const' : member function already defined or declared
    c:\program files\microsoft visual studio 8\vc\include\comutil.h(998) : see declaration of '_variant_t::operator int'
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1037) : error C2535: '_variant_t &_variant_t::operator =(int)' : member function already defined or declared
    c:\program files\microsoft visual studio 8\vc\include\comutil.h(1029) : see declaration of '_variant_t::operator ='
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1331) : error C2084: function '_variant_t::_variant_t(int) throw()' already has a body
    c:\program files\microsoft visual studio 8\vc\include\comutil.h(970) : see previous definition of '{ctor}'
c:\program files\microsoft visual studio 8\vc\include\comutil.h(1588) : error C2084: function '_variant_t::operator int(void) const' already has a body
    c:\program files\microsoft visual studio 8\vc\include\comutil.h(998) : see previous definition of '.H'
c:\program files\microsoft visual studio 8\vc\include\comutil.h(2006) : error C2084: function '_variant_t &_variant_t::operator =(int)' already has a body
    c:\program files\microsoft visual studio 8\vc\include\comutil.h(1029) : see previous definition of '='

There is probably some configuration that is incorrect, some define missing or some include file I should have included but I can't seem to find the problem. Any pointers in the right direction is much appreciated

This looks like one of two things, an include order problem or as you stated something not getting defined but I am leaning towards the first one. You might want to check msdn and make sure there are no restrictions on when comutil.h can be included (I know this is an issue if you include winsock2.h before windows.h). There is also an option under C/C++ > Advanced to Show Includes (/showIncludes option from the command-line) which is generally helpful when trying to track issues like this down.

您自己的代码是否执行以下操作:

#define long int

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM