我需要在ARM平台上编译cppunit。在发布模式下所有编译和工作正常,但在调试模式下我收到以下错误:
Error 1 error C2664: 'unsigned int CppUnit::_InterlockedIncrement(volatile unsigned int *)' : cannot convert argument 1 from 'volatile long *' to 'volatile unsigned int *' C:\Program Files (x86)\Windows Phone Kits\8.1\Include\winbase.h 8959 1 cppunit
Error 2 error C2665: 'CppUnit::_InterlockedIncrement' : none of the 2 overloads could convert all the argument types C:\Program Files (x86)\Windows Phone Kits\8.1\Include\winbase.h 8968 1 cppunit
Error 3 error C2664: 'unsigned int CppUnit::_InterlockedDecrement(volatile unsigned int *)' : cannot convert argument 1 from 'volatile long *' to 'volatile unsigned int *' C:\Program Files (x86)\Windows Phone Kits\8.1\Include\winbase.h 8990 1 cppunit
Error 4 error C2665: 'CppUnit::_InterlockedDecrement' : none of the 2 overloads could convert all the argument types C:\Program Files (x86)\Windows Phone Kits\8.1\Include\winbase.h 8999 1 cppunit
Error 5 error C2664: 'unsigned int CppUnit::_InterlockedExchange(volatile unsigned int *,unsigned int)' : cannot convert argument 1 from 'volatile long *' to 'volatile unsigned int *' C:\Program Files (x86)\Windows Phone Kits\8.1\Include\winbase.h 9024 1 cppunit
Error 6 error C2665: 'CppUnit::_InterlockedExchange' : none of the 2 overloads could convert all the argument types C:\Program Files (x86)\Windows Phone Kits\8.1\Include\winbase.h 9034 1 cppunit
Error 7 error C2664: 'unsigned int CppUnit::_InterlockedExchangeAdd(volatile unsigned int *,unsigned int)' : cannot convert argument 1 from 'volatile long *' to 'volatile unsigned int *' C:\Program Files (x86)\Windows Phone Kits\8.1\Include\winbase.h 9058 1 cppunit
Error 8 error C2664: 'unsigned int CppUnit::_InterlockedExchangeAdd(volatile unsigned int *,unsigned int)' : cannot convert argument 1 from 'volatile long *' to 'volatile unsigned int *' C:\Program Files (x86)\Windows Phone Kits\8.1\Include\winbase.h 9068 1 cppunit
Error 9 error C2665: 'CppUnit::_InterlockedExchangeAdd' : none of the 2 overloads could convert all the argument types C:\Program Files (x86)\Windows Phone Kits\8.1\Include\winbase.h 9078 1 cppunit
Error 10 error C2665: 'CppUnit::_InterlockedExchangeAdd' : none of the 2 overloads could convert all the argument types C:\Program Files (x86)\Windows Phone Kits\8.1\Include\winbase.h 9088 1 cppunit
Error 11 error C2664: 'unsigned int CppUnit::_InterlockedCompareExchange(volatile unsigned int *,unsigned int,unsigned int)' : cannot convert argument 1 from 'volatile long *' to 'volatile unsigned int *' C:\Program Files (x86)\Windows Phone Kits\8.1\Include\winbase.h 9123 1 cppunit
Error 12 error C2665: 'CppUnit::_InterlockedCompareExchange' : none of the 2 overloads could convert all the argument types C:\Program Files (x86)\Windows Phone Kits\8.1\Include\winbase.h 9134 1 cppunit
我已经为此苦苦挣扎了好几天,但我真的找不到任何解决方案。 我正在使用 Visual Studio 2013。
遇到同样的事情 - 似乎您是从名称空间内部包含的(在您的情况下是 CppUnit )。编译器不喜欢这样 - 确保你的 #include 位于所有命名空间之外。
如果您使用 C++,您可以定义
NOWINBASEINTERLOCK
来省略 Interlocked*
中的 Windows.h
函数,并使用类似 std::atomic
的内容来代替。