Michal
Michal

Reputation: 11

Interlocked functions - cannot convert arguments

I need to compile cppunit on ARM platform. All compiles and works fine on release mode, but on debug mode I get following errors:

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

I am struggling with it for days now, and I cannot really find any solution to this. I am using visual studio 2013.

Upvotes: 1

Views: 1129

Answers (2)

23Xor
23Xor

Reputation: 44

Just a hint: mingw users may define NOWINBASEINTERLOCK to omit Interlocked* functions in Windows.h and use something like std::atomic instead.

Upvotes: 0

Angus H
Angus H

Reputation: 111

Ran in to the same thing - seems like you're including from inside a namespace (CppUnit in your case). The compiler doesn't like that - make sure your #include is outside of all namespaces.

Upvotes: 1

Related Questions