2013-03-12 144 views
1

您好我有编译下面指定的代码的InterlockedIncrement':标识符在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':标识符找不到

回答

2

InterlockedIncrement()函数接受volatile long &,而你传递一个volatile long *,因此编译器无法找到相应的函数签名。