2013-03-12 146 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 *,因此編譯器無法找到相應的函數簽名。