Boost logo

Boost :

Subject: Re: [boost] Boost.Atomic on Windows, patch
From: Václav Zeman (vhaisman_at_[hidden])
Date: 2012-08-04 03:02:43

On 08/03/2012 07:43 PM, Sergey Cheban wrote:
> On 03.08.2012 14:43, Václav Zeman wrote:
>>> Why is neccessary to include the windows headers at all? Intrin.h
>>> seems to
>>> be enough: it declares _InterlockedCompareExchange and some other
>>> useful
>>> intrinsics, and it does not use the winapi-related stuff.
>>> Checked on MSVC 2008 and 2010. I remember that I had some problems with
>>> interlocked functions and intrinics several years ago (with MSVC6,
>>> probably), but now I cannot reproduce them.
>> Both intrin.h and windows.h do declare the intrinsic functions using
>> #pragma intrinsic.
> No. Windows.h does not declare _InterlockedCompareExchange at all.
> Instead, it declares InterlockedCompareExchange (without underscore)
> that is not an intrinsic but a function implemented in the
> Kernel32.lib. For the x86, there is also an implementation in the
> kernel32.dll but the programs that were built with modern versions of
> the Windows SDK don't use it.
I can see the #pragma intrinsic bits in WinNT.h which is included by
WinDef.h which is included by Windows.h. But maybe there is some macro
symbols trickery that make it ineffective.

> The following does not work:
> #include <windows.h>
> void f()
> {
> long l;
> _InterlockedCompareExchange( &l, 0,0 );
> //error C3861: '_InterlockedCompareExchange': identifier not found
> }
> So, windows.h and winsock2.h are useless for those who want to use
> _InterlockedCompareExchange.


Boost list run by bdawes at, gregod at, cpdaniel at, john at