assert.h

来自「汇编代码大全」· C头文件 代码 · 共 49 行

H
49
字号
/* @(#) assert.h 2.1 87/12/25 12:21:32 */

/*
The contents of this file are hereby released to the public domain.

                           -- Rahul Dhesi 1991/07/04

Defines a macro assert() that causes an assertion error if the assertion
fails.

Conditional compilation:

   If NDEBUG is defined then
      assert() is defined as null so all assertions vanish
   else
		if __FILE__ and __LINE__ are defined then
         assertions print message including filename and line number
      else
         assertions print a message but not the filename and line number
      endif
   endif
*/

#ifdef NDEBUG
# define assert(E)
#else

#undef LINE_FILE

#ifdef __LINE__
# ifdef __FILE__
#  define LINE_FILE
# endif
#endif

#ifdef LINE_FILE
# undef LINE_FILE
# define assert(E) \
   { if (!(E)) \
      prterror ('w',"Assertion error in %s:%d.\n", __FILE__, __LINE__); \
   }
#else
# define assert(E) \
   { if (!(E)) \
      prterror ('w', "Assertion error.\n"); \
   }
#endif
#endif /* NDEBUG */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?