Opened 15 years ago
Closed 15 years ago
#1069 closed Bugs (invalid)
_InterlockedExchange, _InterlockedExchangeAdd have wrong signature
Reported by: | Owned by: | Peter Dimov | |
---|---|---|---|
Milestone: | To Be Determined | Component: | smart_ptr |
Version: | Boost 1.34.0 | Severity: | Problem |
Keywords: | Cc: |
Description
Microsoft describes the signature of _InterlockedExchange
as
extern "C" LONG __cdecl _InterlockedExchange(LPLONG volatile Target, LONG Value);
See http://msdn2.microsoft.com/en-us/library/f24ya7ct(VS.71).aspx
In boost/detail/intrinsic.hpp, this function gets declared as
extern "C" __declspec(dllimport) long __stdcall InterlockedExchange( long volatile *, long );
The problem is that LPLONG volatile
is equivalent to long * volatile
, not long volatile *
. This results in compilation failures in the presence of a correct declaration of this function; i.e., the compiler complains that you cannot overload C functions.
Attachments (1)
Change History (6)
by , 15 years ago
Attachment: | interlocked.patch added |
---|
comment:1 by , 15 years ago
As suggested in the summary, the declaration of _InterlockedExchangeAdd has the same problem.
comment:2 by , 15 years ago
Component: | Building Boost → smart_ptr |
---|---|
Owner: | set to |
Severity: | Showstopper → Problem |
Status: | new → assigned |
On which compiler are you seeing this behavior? The actual declaration in <windows.h> is as follows:
WINBASEAPI LONG WINAPI InterlockedExchange(
IN OUT LONG volatile *Target, IN LONG Value );
with the volatile correctly applied to *Target.
comment:3 by , 15 years ago
The compiler is Visual C++ 7.1. The problem arises because code in another dependency has declared the function the way the Microsoft documentation recommends. Since the signatures are different, the compiler complains that an extern "C"
function has been overloaded.
comment:4 by , 15 years ago
The Microsoft documentation is wrong in this case. If we change the code to be wrong as well, the signatures will no longer match the ones in <windows.h>. The documentation for InterlockedExchange
http://msdn2.microsoft.com/en-us/library/ms683590.aspx
correctly specifies the signature as taking LONG volatile*. BTW, you can't declare a function parameter as long * volatile, the volatile is ignored.
comment:5 by , 15 years ago
Resolution: | → invalid |
---|---|
Status: | assigned → closed |
Patch