我在Windows 7计算机上编译Visual Studio 2010中的程序时遇到问题。我在发布模式下编译时遇到以下错误,但在调试模式下没有。我仔细检查了两种模式的所有属性设置,它们是相同的,除了它们必须不同的地方;代码生成设置是/ MD for Runtime,/ MDd for Debug,与我编译wxWidgets(2.8.12)库的设置相同,并且wxWidgets库的名称略有不同。正如我所说的,在调试模式下编译和运行程序,或者在任一模式下运行wxWidgets样本都没有问题。我也链接到wxMathPlot,这是一个wxWidgets附加组件,我不知道这是否相关。我可以运行wxMathPlot样本的调试或发布版本。
现在微软有关于这些编译器错误的一些信息,但没有任何帮助我太多:
http://msdn.microsoft.com/en-us/library/3ys51zwc(v=vs.71).aspx http://msdn.microsoft.com/en-us/library/sksadsda.aspx
这句话似乎相关: “如果您不止一次将类型库导入同一个文件,您也可能会获得C2011”
除了我不知道这意味着什么,或者我怎么做。好奇的是,我会为一种模式而不是另一种模式。有没有人见过这个问题,知道如何克服它?
由于 菲尔
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.h(124): error C2332: 'class' : missing tag name
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.h(124): error C2011: '<unnamed-tag>' : 'enum' type redefinition
1> C:\WXWIDGETS\wxWidgets-2.8.12\include\wx/app.h(48) : see declaration of '<unnamed-tag>'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.h(124): error C2059: syntax error : 'constant'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.h(125): error C2143: syntax error : missing ')' before '>'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.h(131): error C2065: 'pp' : undeclared identifier
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.h(134): warning C4229: anachronism used : modifiers on data are ignored
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.h(134): error C2365: 'IUnknown::QueryInterface' : redefinition; previous definition was 'member function'
1> C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.h(116) : see declaration of 'IUnknown::QueryInterface'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.h(134): error C2998: 'HRESULT QueryInterface' : cannot be a template definition
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.h(316): error C2989: 'AsyncIUnknown' : class template has already been declared as a non-class template
1> C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.h(59) : see declaration of 'AsyncIUnknown'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.h(434): error C2989: 'IClassFactory' : class template has already been declared as a non-class template
1> C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\unknwn.h(65) : see declaration of 'IClassFactory'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(269): error C2989: 'IRpcChannelBuffer' : class template has already been declared as a non-class template
1> c:\program files (x86)\microsoft sdks\windows\v7.0a\include\rpcndr.h(708) : see declaration of 'IRpcChannelBuffer'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(305): error C2989: 'IRpcStubBuffer' : class template has already been declared as a non-class template
1> c:\program files (x86)\microsoft sdks\windows\v7.0a\include\rpcndr.h(2489) : see declaration of 'IRpcStubBuffer'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(653): error C2143: syntax error : missing ';' before 'identifier'
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(653): warning C4091: 'typedef ' : ignored on left of '_COSERVERINFO' when no variable is declared
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(653): fatal error C1075: end of file found before the left brace '{' at 'C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\objidl.h(595)' was matched
这是从unknwn.h文件中抱怨的一段代码,从第124行开始:
template<class Q>
HRESULT
#ifdef _M_CEE_PURE
__clrcall
#else
STDMETHODCALLTYPE
#endif
QueryInterface(Q** pp)
{
return QueryInterface(__uuidof(Q), (void **)pp);
}