winapiinterlockedwindows-98

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)?


Solution

  • 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);