8

I have include windows.h and want to use InterlockedAdd in vs2010 and compiles error "identifier not found", but the InterlockedIncrement can work well. I try to use:

#include <intrin.h>
#pragma intrinsic(_InterlockedAdd) 

and compiles error:

warning C4163: '_InterlockedAdd' : not available as an intrinsic function
1>test10.cpp(107): error C3861: 'InterlockedAdd': identifier not found

What's wrong with the code?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
magicyang
  • 453
  • 1
  • 5
  • 14
  • http://connect.microsoft.com/VisualStudio/feedback/details/524100/interlockedadd-is-where seems to talk about it – jcoder Jan 30 '13 at 12:03

1 Answers1

16

The InterlockedAdd function is only available on the Itanium platform. On x86 and x86-64 platforms you can use InterlockedExchangeAdd instead. This also adds a value to the target variable, but it returns the original value instead of the new value.

interjay
  • 107,303
  • 21
  • 270
  • 254