完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
从我所看到的,这用于检查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 functions. 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 */ |
|
相关推荐
4个回答
|
|
首先,如果添加导致错误的代码,那么它们按照定义是RELATED。
其次,assert_param()宏不用于检查'C'库函数参数,与Cosmic提供的任何内容完全无关。它用于验证ST提供的STM8FirmwareLibrary中的参数。 (一个图书馆,在我看来更糟,然后没用,因为你可以看到人们遇到的所有问题)。 assert_param宏在''stm8s_conf.h'中定义,应该从stm8s.h加载。您需要做的就是定义USE_FULL_ASSERT .. 以上来自于谷歌翻译 以下为原文 First, if you add code that causes errors then they are by definition RELATED. Second, the assert_param() macro is NOT used in checking the 'C' library function parameters and is totally unrelated to anything provided by Cosmic. It is used instead in verifying the parameters in the STM8FirmwareLibrary provided by ST. (a library which in my own opinion is worse then useless as you can see by all the problems people are having with it). The assert_param macro is defined in ''stm8s_conf.h'' which should be loaded from stm8s.h. All you need to do to enable it is to define USE_FULL_ASSERT.. |
|
|
|
约翰,
我知道为什么使用断言但我只是认为这是我设置项目的方式我将删除断言的任何实例只是为了让它继续下去。应该有一个关于用普通人可以理解的简单术语来设计项目的文档。 ST希望你通过使用他们的微型计算机赚钱,但他们没有告诉你如何正确地做到这一点它需要的不仅仅是数据表。我尝试了你说的但是没有用,我看了一下切换示例,文件结构看起来非常不同于我的。谢谢回复。 以上来自于谷歌翻译 以下为原文 H John, I know why the assert is used but I just think it's the way I have my project set up I'm going to delete any instances of the assert just to get it going. There should be a doc on seting up the projects in plain terms that normal people can understand. ST want you to make them money by using their micros but they fail to tell you how to do this correctly it requires alot more than a datasheet. I tried what you said but that didn't work, I've looked at the toggle example and the file structure look very differant to mine. Thnaks for the reply. |
|
|
|
在stm8s.h中取消注释#define USE_STDPERIPH_DRIVER
以上来自于谷歌翻译 以下为原文 uncomment #define USE_STDPERIPH_DRIVER in stm8s.h |
|
|
|
这不是无用的,它可能是usebad。
|
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2745 浏览 1 评论
3244 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1813 浏览 1 评论
3655 浏览 6 评论
6044 浏览 21 评论
1342浏览 4评论
204浏览 3评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
359浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
447浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
276浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-28 13:24 , Processed in 1.159449 second(s), Total 82, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号