Ivars
Ivars

Reputation: 2413

InterlockedCompareExchange in windows 98 environment

I am forced to run some applications in windows 98 se. vc6 has strange InterlockedCompareExchange definition:

void* InterlockedCompareExchange(void**, void*, void*);

msdn defines it like this however (since windows xp):

LONG InterlockedCompareExchange(LONG*, LONG, LONG);

Does anyone remembers how to use it (I need to atomically get value of interlocked variable)?

Upvotes: 1

Views: 158

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 596602

Windows 98 did not support 64bit, so void* and LONG are the same byte size. Most OSes actually use the LONG definition, but if VC6 is using `void* then simply type-cast where needed:

LONG value;
LONG ret = (LONG) InterlockedCompareExchange((void**)&value, (void*)ExchangeValue, (void*)CompareValue);

Upvotes: 1

Related Questions