診斷<assert.h>
assert
#include <assert.h> void assert(int exp);
assert宏用於為程序增加診斷功能。當assert(exp)執行時,如果exp為0,則在標准出錯輸出流stderr輸出一條如下所示的信息:
Assertion failed: expression, file filename, line nnn
然后調用abort終止執行。其中的源文件名filename和行號nnn來自於預處理宏__FILE__和__LINE__。
如果<assert.h>被包含時定義了宏NDEBUG,那么宏assert被忽略。