谷动谷力

 找回密码
 立即注册
查看: 2084|回复: 2
打印 上一主题 下一主题
收起左侧

RT-Thread添加软件包会出现uint8_t uint16_t uint32_t size_t NULL未定义

[复制链接]
跳转到指定楼层
楼主
发表于 2021-12-1 23:33:40 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
RT-Thread添加软件包会出现uint8_t uint16_t  uint32_t size_t NULL未定义错误




描述:
RT-Thread添加软件包会出现uint8_t uint16_t  uint32_t size_t未定义
大致出错内容,如下:
riscv64-unknown-elf-gcc "../applications/blehr_app.c"
../applications/blehr_app.c:25:40: error: unknown type name 'uint16_t'; did you mean 'rt_uint16_t'?
   25 | void bthw_get_heap_info(void **p_heap, uint16_t **p_heap_size, uint32_t *p_block_size);
      |                                        ^~~~~~~~
      |                                        rt_uint16_t
../applications/blehr_app.c:25:64: error: unknown type name 'uint32_t'; did you mean 'rt_uint32_t'?
   25 | void bthw_get_heap_info(void **p_heap, uint16_t **p_heap_size, uint32_t *p_block_size);
      |                                                                ^~~~~~~~
      |                                                                rt_uint32_t
../applications/blehr_app.c:26:73: error: unknown type name 'uint32_t'; did you mean 'rt_uint32_t'?
   26 | typedef void (*nsmem_cb_init_func)(void *heap_buf, void *heap_size_buf, uint32_t mem_block_max);
      |                                                                         ^~~~~~~~
      |                                                                         rt_uint32_t
../applications/blehr_app.c: In function 'btctrl_mem_init':
../applications/blehr_app.c:32:5: error: unknown type name 'uint16_t'; did you mean 'rt_uint16_t'?
   32 |     uint16_t *heap_size_buf;
      |     ^~~~~~~~
      |     rt_uint16_t
../applications/blehr_app.c:33:5: error: unknown type name 'uint32_t'; did you mean 'rt_uint32_t'?
   33 |     uint32_t block_size;
      |     ^~~~~~~~
      |     rt_uint32_t
../applications/blehr_app.c:35:5: warning: implicit declaration of function 'bthw_get_heap_info' [-Wimplicit-function-declaration]
   35 |     bthw_get_heap_info(&heap_buf, &heap_size_buf, &block_size);
      |     ^~~~~~~~~~~~~~~~~~
../applications/blehr_app.c:27:27: error: 'nsmem_cb_init_func' undeclared (first use in this function); did you mean 'nsmem_cb_init'?
   27 | #define nsmem_cb_init   ((nsmem_cb_init_func)0x84140)
      |                           ^~~~~~~~~~~~~~~~~~
../applications/blehr_app.c:36:5: note: in expansion of macro 'nsmem_cb_init'
   36 |     nsmem_cb_init(heap_buf, heap_size_buf, block_size);
      |     ^~~~~~~~~~~~~
../applications/blehr_app.c:27:27: note: each undeclared identifier is reported only once for each function it appears in
   27 | #define nsmem_cb_init   ((nsmem_cb_init_func)0x84140)
      |                           ^~~~~~~~~~~~~~~~~~
../applications/blehr_app.c:36:5: note: in expansion of macro 'nsmem_cb_init'
   36 |     nsmem_cb_init(heap_buf, heap_size_buf, block_size);
      |     ^~~~~~~~~~~~~
../applications/blehr_app.c:27:46: error: expected ')' before numeric constant
   27 | #define nsmem_cb_init   ((nsmem_cb_init_func)0x84140)
      |                         ~                    ^~~~~~~
../applications/blehr_app.c:36:5: note: in expansion of macro 'nsmem_cb_init'
   36 |     nsmem_cb_init(heap_buf, heap_size_buf, block_size);
      |     ^~~~~~~~~~~~~
make: *** [applications/subdir.mk:24: applications/blehr_app.o] Error 1
"make -j4 all2" terminated with exit code 2. Build might be incomplete.








原因:
RT-Thread定义数据类型,使用rt前缀,如rt_uint8_t rt_uint16_t  rt_uint32_t rt_size_t等
而开源代码是的大家常用,标准C库定义的uint8_t uint16_t  uint32_t size_t数据类型
RT-Thread移植未改过来数据类型定义,头文件也没有加





解决方法:
添加头文件
#include <stdint.h>
#include <stddef.h>


当然添加上面的头文件,不能解决所有问题,像这个问题,就要自己在代码里找了. RT-Thread Studio 方法: 双击错误内容, 在源码里选中这个变量,cltr+双击,定位到定义的位置, 把对应的的头文件加上即可.

千万不要像图中说的,删除掉,这样会影响功能的.  

如果还找到定义头文件, 可以临时,注释掉, 让编译通过,也不能删除掉哦.
还有个方法, 没定义的话,自己定义一下, 也可以的. 不过这样话, 也有风险, 原本定义过的, 再定义会出错:重复定义.

还有很可能是配置时,少加载了驱动 \BSP\软件功能包, 这个方法比较复杂, 具体问题要具体分析. 要了解整个开源项目代码结构,相关依赖项目. 这种问题, 网上找答案, 或我们谷动谷力\RT-Thread\电子发烧友....等发贴资咨询. 也可以私信我们.







建议:
RT-Thread官可以统一用标准C库定义的uint8_t uint16_t  uint32_t size_t数据类型, 使用我们的代码更有通用性。
大家写代码也用标准C库定义的uint8_t uint16_t  uint32_t size_t数据类型,不用使用rt前缀,如rt_uint8_t rt_uint16_t  rt_uint32_t rt_size_t NULL等



回复

使用道具 举报

沙发
 楼主| 发表于 2021-12-3 11:56:26 | 只看该作者
还是建议:
RT-Thread官可以统一用标准C库定义的uint8_t uint16_t uint32_t size_t数据类型, 使用我们的代码更有通用性。
大家写代码也用标准C库定义的uint8_t uint16_t uint32_t size_t数据类型,不用使用rt前缀,如rt_uint8_t rt_uint16_t rt_uint32_t rt_size_t等,能统一一下
用这个RTOS目的,就是引用通过软件包,一人开发,所有开发者享用
配置的软件包,能一次性编译通过,如果加载软件包多,改起来,还是有点麻烦,开发者多,如有1亿开发者,每个开发者改这个编译错误用时5分(加重复编译时间)哪么总体开发效率,就整体延误了5亿分钟,想想一个人生命里,有几个5亿分钟
回复 支持 反对

使用道具 举报

板凳
 楼主| 发表于 2021-12-4 18:57:35 | 只看该作者
希望RT-Thread官方可以重视这个问题,最起码加载软件包可以编译通过吧.还有很多小伙伴,不能在5分钟解决这个基础问题.





回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|深圳市光明谷科技有限公司|光明谷商城|Sunshine Silicon Corpporation ( 粤ICP备14060730号|Sitemap

GMT+8, 2024-4-20 17:45 , Processed in 0.110584 second(s), 41 queries .

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表