c++ - '互锁增量' : identifier not found error in visual c++ 2008

标签 c++ visual-c++-2008

你好,我已经编译了下面指定的代码

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/

相关文章:

c++ - 编译 C++ 代码后的大尺寸

c++ - c++中 "unsigned long int"的最大值

c++ - 如何使用 sqlite3_exec 从 sqlite3 数据库中选择数据到变量中?

C++计算数组中正数/负数的数量

c# - 我可以控制分配给互操作程序集的版本号吗?

c++ - vc9 和 gcc 之间不同的析构函数行为

C++11 大括号/聚合初始化。什么时候使用它?

visual-c++ - fatal error LNK1112 : module machine type 'x64' conflicts with target machine type 'X86'

c++ - 如何递归取消引用指针(C++03)?

c++ - 如何在 Visual C++ 2008 中查看完整输出