C++ 移动Windows C++;从Qt4到5的项目给出了数百个看似无关的编译错误

C++ 移动Windows C++;从Qt4到5的项目给出了数百个看似无关的编译错误,c++,qt,winapi,visual-c++,com,C++,Qt,Winapi,Visual C++,Com,我升级到Qt5/msvc2010,现在正尝试使用Qt Creator构建一个项目,该项目在Qt4/msvc2008中运行良好(自运行以来,没有任何源代码发生更改) 该项目使用一些COM元素通过Olympus SDK与外部录音设备进行对话 在我升级到Qt5之前,一切正常,是什么导致了所有这些错误?据我所知,这些错误中列出的类都没有被我的项目实际使用 我已经尝试在每个头文件中尽可能包含定义相关类的文件(例如,IEnumConnections的ocidl.h),甚至将包含的顺序切换到许多不同的组合也无

我升级到Qt5/msvc2010,现在正尝试使用Qt Creator构建一个项目,该项目在Qt4/msvc2008中运行良好(自运行以来,没有任何源代码发生更改)

该项目使用一些COM元素通过Olympus SDK与外部录音设备进行对话

在我升级到Qt5之前,一切正常,是什么导致了所有这些错误?据我所知,这些错误中列出的类都没有被我的项目实际使用

我已经尝试在每个头文件中尽可能包含定义相关类的文件(例如,IEnumConnections的ocidl.h),甚至将包含的顺序切换到许多不同的组合也无济于事

e:\bp\mainwindow.h(21) : warning C4005: 'WINVER' : macro redefinition
        C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\sdkddkver.h(212) : see previous definition of 'WINVER'
e:\bp\mainwindow.h(25) : warning C4005: '_WIN32_WINNT' : macro redefinition
        C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\sdkddkver.h(197) : see previous definition of '_WIN32_WINNT'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(53) : error C2146: syntax error : missing ';' before identifier 'IEnumConnections'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(53) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(53) : error C2146: syntax error : missing ';' before identifier 'IEnumConnections'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(53) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(53) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(53) : error C2086: 'int IEnumConnections' : redefinition
        C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(53) : see declaration of 'IEnumConnections'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(59) : error C2146: syntax error : missing ';' before identifier 'IConnectionPoint'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(59) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(65) : error C2146: syntax error : missing ';' before identifier 'IEnumConnectionPoints'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(65) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(71) : error C2146: syntax error : missing ';' before identifier 'IConnectionPointContainer'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(71) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(77) : error C2146: syntax error : missing ';' before identifier 'IClassFactory2'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(77) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(83) : error C2146: syntax error : missing ';' before identifier 'IProvideClassInfo'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(83) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(89) : error C2146: syntax error : missing ';' before identifier 'IProvideClassInfo2'
C:\Program Files\Microsoft SDKs\Windows\v7.0\Include\ocidl.h(89) : warning C4091: '' : ignored on left of 'interface' when no variable is declared
完整的错误列表如下:

尝试移动#将“windows.h”包含在所有其他包含项之上,和/或包含在对奥林巴斯sdk的所有引用之上

也做一个完整的建设清洁。包括删除任何Makefile或Makefile.debug以及调试和发布文件夹

如果这仍然不能解决问题,那就转向阴影建筑


希望对您有所帮助。

Qt 5中的windows包含已更改。在包含
sdkddkver.h
之后,您需要包含
windows.h

我已经多次尝试了您的所有建议,但似乎没有什么不同。这并不能解决问题。的确,windows.h在某些数学函数等的顶部包含了一个移植问题,但这里的情况并非如此。像宏问题这样的庸医,某种东西正在冲击符号“接口”。使用/P编译以查看发生了什么。请尝试两步升级。首先,更新到MSVC10,看看它是否有效?如果可以的话,尝试升级到Qt5。第一步行得通吗?我实际上没有在任何地方包含该文件,奥林巴斯SDK也没有。即使完全忽略Windows SDK的包含路径,也不会改变任何东西。不知怎的,它还是被包含了(可能是MSVC编译器?)@bparker:有些东西确实包含了它,所以你需要弄清楚到底是什么。如果您希望我们对此提供帮助,请提供更多代码。你到底包括哪些windows头?似乎windows.h是通过包含QMainWindow而被包含的,所以我不得不将我的COM头包含移到上面,现在它正在工作。