你好,我已经编译了下面指定的代码
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
}
在 g++ 编译器中它会工作正常。但是当我在 Visual C++ 2008 中尝试同样的操作时,它显示了下面指定的错误。我能解决这个问题吗?
错误 5 错误 C3861:“InterlockedIncrement”:找不到标识符
最佳答案
InterlockedIncrement()
函数采用 volatile long &
,而您传递给它的是 volatile long *
,因此编译器不能找不到对应的函数签名。
关于c++ - '互锁增量' : identifier not found error in visual c++ 2008,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15354595/