我在将旧项目从VS6转换为VS2005时遇到了一些麻烦。在代码中的一个位置它使用类型variant_t,因此它包含comdef.h用于此目的。 comdef.h然后包含comutil.h,它为我生成这些错误:
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 '='
可能有一些配置不正确,一些定义缺失或一些我应该包含的包含文件,但我似乎无法找到问题。任何指向正确方向的人都非常感激
答案 0 :(得分:0)
这看起来像两件事之一,包括订单问题,或者你说的东西没有定义,但我倾向于第一个。您可能想检查msdn并确保对comutil.h的包含时没有限制(如果在windows.h之前包含winsock2.h,我知道这是一个问题)。在C / C ++下还有一个选项>高级显示包含(来自命令行的/ showIncludes选项),这在尝试跟踪此类问题时通常很有用。
答案 1 :(得分:-1)
你自己的代码是这样的:
#define long int