assert.h
This is a macro function assertion during a debug, the compiler does not participate in the release program.
CMakeLists.txt:
# Default No configuration is compiled Debug version. Explicitly configured as Debug or Release
the SET (CMAKE_BUILD_TYPE "Debug")
#SET (CMAKE_BUILD_TYPE "Release")
use
#include <assert.h>
assert(3 > 0); //()内是一个表达式
char *p = "stone";
assert(p); //真
char *q;
assert(q); //假
assert(3 > 4); //断言失败,程序退出。 后续不再执行。