Question

hi i have compiled the below specified code

long (*interlocked_increment) (volatile long *);
long InterlockedIncrement(volatile long & value) const {
        return interlocked_increment(&value);
      }
static long m_interlocked_increment(volatile long * pv) {
#ifdef WIN32
  return InterlockedIncrement(pv); 
#elif defined(HAS_SYNC_FUNCTIONS)
  return __sync_fetch_and_add(pv, 1L);
#else
  return ++(*pv);
#endif
}

in g++ compiler it will works fine. but while i try the same in visual c++ 2008 it shows the below specified error.ho can i resolve this problem.

Error 5 error C3861: 'InterlockedIncrement': identifier not found

Was it helpful?

Solution

The InterlockedIncrement() function takes volatile long &, whereas you're passing it a volatile long *, thus the compiler can't find the corresponding function signature.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top