问题
I upgraded to Qt5/msvc2010 and am now trying to build a project using Qt Creator that was working fine with Qt4/msvc2008 (no source code has changed since it was working).
The project uses some COM elements to talk to external audio recording devices via an Olympus SDK.
What could cause all of these errors when everything was working fine before I upgraded to Qt5? To my knowledge none of the classes listed in these errors are actually used by my project.
I've tried including files that define the classes in question (e.g. ocidl.h for IEnumConnections) in every header file possible, even switching the order of includes to many different combinations to no avail.
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
Full error listing is here: http://dpaste.com/1525608/
回答1:
The windows inclusion has been changed in Qt 5. You will need to include the windows.h after your sdkddkver.h inclusion.
回答2:
Try moving #include "windows.h" above all your other includes, and/or above every reference to olympus sdk.
Also do a full build clean. Including deleting any Makefile, or Makefile.debug and your debug and release folders.
If that still doesn't fix it, turn of shadow building.
Hope that helps.
来源:https://stackoverflow.com/questions/20805090/moving-windows-c-project-from-qt4-to-5-gives-hundreds-of-seemingly-unrelated-c