assert_param的原型定义在stm32f10x_conf.h 文件里
定义如下:
- #ifdef DEBUG
-
- #define assert_param(expr) ((expr) ? (void)0 : assert_failed((u8 *)__FILE__, __LINE__))
- void assert_failed(u8* file, u32 line);
- #else
- #define assert_param(expr) ((void)0)
- #endif
- #endif
可以看到assert_param实际在DEBUG打开时就是assert_failed,关闭DEBUG时是空函数
assert_failed函数如下
- #ifdef DEBUG
- void assert_failed(u8* file, u32 line)
- {
-
- //用户可以在这里添加错误信息:比如打印出出错的文件名和行号
-
- while (1)
- {
- }
- }
- #endif
|