从我所看到的,这用于检查c库函数中的参数。
我试图将其添加到头文件中,但是当我这样做时,编译器会创建许多不相关的错误。
这是我要补充的: -
有没有人有同样的问题?
我把它放到顶部.h文件中#define USE_FULL_ASSERT(1)
/ *导出的宏---------------------------------------------- -------------- * /
#ifdef USE_FULL_ASSERT / **
* @brief assert_param宏用于函数的参数检查。
* @param expr:如果expr为false,则调用assert_failed函数
*报告源文件的名称和来源
*失败的呼叫的行号。
*如果expr为true,则不返回任何值。
* @retval:无
* /
#define assert_param(expr)((expr)?(void)0:assert_failed((uint8_t *)__ FILE __,_ _ _ __))
/ *导出的函数---------------------------------------------- --------- * /
void assert_failed(uint8_t * file,uint32_t line);
#其他
#define assert_param(expr)((void)0)
#endif / * USE_FULL_ASSERT * /
以上来自于谷歌翻译
以下为原文
From what I can see this is used to check in parameters into the c library func
tions.
I've tried to add this to a header file but when I do so the compiler creates many unrelated errors.
This is what I am adding:-
Has anyone had the same problem?
I'm putting it into the top .h file #define USE_FULL_ASSERT (1)
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
* @retval : None
*/
#define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0)
#endif /* USE_FULL_ASSERT */
0