c加加assert(C++,assert(argc == 2);这语句是什么意思)

本文目录
C++,assert(argc == 2);这语句是什么意思
The definition of the macro assert depends on another macro, NDEBUG, which is not defined by the standard library.
If NDEBUG is defined as a macro name at the point in the source code where 《cassert》 is included, then assert does nothing.
If NDEBUG is not defined, then assert checks if its argument (which must have scalar type) compares equal to zero. If it does, assert outputs implementation-specific diagnostic information on the standard error output and calls std::abort. The diagnostic information is required to include the text of expression, as well as the values of the standard macros __FILE__, __LINE__, and the standard variable __func__.
非调试状态下,什么也不做。
在调试状态下,如果判断条件不为真,将会结束程序,提示错误信息
关于C语言中assert等语法在嵌入式应用当中的含义
assert_param(IS_GPIO_MODE(GPIO_InitStruct-》GPIO_Mode));
意思是:IS_GPIO_MODE(GPIO_InitStruct-》GPIO_Mode)这个判断条件必须为真,否则程序就会进入死循环。
一般assert用来判断必须为真的一些条件,防止程序出现意外错误。
例如:
assert(汽车有4个轮子)//这个是必须成立的条件
开汽车

更多文章:
全球新冠肺炎疫情背景下航运发展(盐田港复苏日志:半年历劫从“低谷”到“爆仓” 疫情之后巨轮如何越洋航行)
2026年9月7日 17:10
matlab求解带字母参数方程组(我想matlab求一个关于x,y的方程组 ab c d f e h m n 都是参数)
2026年9月7日 16:30
oracle中的循环语句(下面哪个不是oracle程序设计中的循环语句 a for)
2026年9月7日 15:30
电脑里2个系统怎么删除一个(电脑开机显示有两个系统,如何删除一个)
2026年9月7日 12:20
scrollthrough意思(“scroll”是什么意思)
2026年9月7日 08:00
怎么激活keygen(注册机如何激活cad2008一个简单激活cad2008的方法)
2026年9月7日 06:30






