assert(condition); 语句是条件编译的。在构建调试(debug)版本时,定义 _DEBUG 预处理符号,使 assert() 评估其条件(如果条件为 false,则终止程序执行)。在构建发布(release)版本时,定义 NDEBUG 预处理符号,使 assert() 不生成任何机器代码,从而提高运行效率。

Last modified: Thursday, 30 January 2025, 1:17 PM