C language "assert.h" asserted Debug

Article Directory


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); //断言失败,程序退出。 后续不再执行。

Published 400 original articles · won praise 364 · Views 1.62 million +

Guess you like

Origin blog.csdn.net/jjwwmlp456/article/details/104453081