2011-12-14 58 views
2

在創建.exe項目時出現錯誤。錯誤是: 編譯...定義_DEBUG時不能定義NDEBUG

1> KsmXmlXalan.cpp 
1>c:\newdir\xalan-c-r786300\inc\xalanc\include\vcppdefinitions.hpp(73): fatal error C1189: #error : NDEBUG must not be defined when _DEBUG is defined. 
1> KsmXmlJB.cpp 
1> KsmXml.cpp 
1>c:\newdir\xalan-c-r786300\inc\xalanc\include\vcppdefinitions.hpp(73): fatal error C1189: #error : NDEBUG must not be defined when _DEBUG is defined. 
1> KsmXalan.cpp 
1>c:\newdir\xalan-c-r786300\inc\xalanc\include\vcppdefinitions.hpp(73): fatal error C1189: #error : NDEBUG must not be defined when _DEBUG is defined. 

雖然我還沒有定義_DEBUG(在項目 - >屬性 - > C/C++ - > Preprocessors->預處理Definations),但仍得到相同的錯誤。

任何人都可以指導爲什麼它給這個錯誤?

先感謝, 問候, 納格什

回答

0

_DEBUG被沿途某處定義。

你可以做一個簡單的事情,但:

#ifdef _DEBUG 
#undef _DEBUG 
#define DEBUG_WAS_DEFINED 
#endif 

#include "vcppdefinitions.hpp" 

//.... 

#ifdef DEBUG_WAS_DEFINED 
#undef DEBUG_WAS_DEFINED 
#define _DEBUG 
#endif 

誤差與非調試庫混合調試時,通常會發生。

2

_DEBUG總是由預處理器在針對「調試」運行時庫生成時預定義的。有關詳細信息,請參閱MSDN庫中的Predefined MacrosDebug Routines

NDEBUG傳統上定義在「發佈」版本中(以除去其他內容中的assert()調用),但它並未由預處理器預定義。

所以它看起來像你正在編譯調試庫,但也有NDEBUG定義的地方。既定義在同一時間可能要求麻煩;頭文件正在檢查並拋出錯誤。