|
新建模板工程编译出现错误:
- ../libraries/hal_drivers/drv_common.c: In function 'uart0_irq_post':
- ../libraries/hal_drivers/drv_common.c:22:5: error: unknown type name 'uint8_t'; did you mean 'rt_uint8_t'?
- 22 | uint8_t mq_msg = MSG_UART0_IRQ;
- | ^~~~~~~
- | rt_uint8_t
- ../libraries/hal_drivers/drv_common.c: In function 'uart1_irq_post':
- ../libraries/hal_drivers/drv_common.c:29:5: error: unknown type name 'uint8_t'; did you mean 'rt_uint8_t'?
- 29 | uint8_t mq_msg = MSG_UART1_IRQ;
- | ^~~~~~~
- | rt_uint8_t
- ../libraries/hal_drivers/drv_common.c: In function 'uart2_irq_post':
- ../libraries/hal_drivers/drv_common.c:36:5: error: unknown type name 'uint8_t'; did you mean 'rt_uint8_t'?
- 36 | uint8_t mq_msg = MSG_UART2_IRQ;
- | ^~~~~~~
- | rt_uint8_t
- ../libraries/hal_drivers/drv_common.c: In function 'drv_thread_entry':
- ../libraries/hal_drivers/drv_common.c:42:5: error: unknown type name 'uint8_t'; did you mean 'rt_uint8_t'?
- 42 | uint8_t mq_msg = 0;
- | ^~~~~~~
- | rt_uint8_t
- make: *** [libraries/hal_drivers/subdir.mk:24: libraries/hal_drivers/drv_common.o] Error 1
- make: *** Waiting for unfinished jobs....
- ../libraries/hal_drivers/drv_usart.c: In function 'rt_hw_usart_init':
- ../libraries/hal_drivers/drv_usart.c:327:42: error: 'NULL' undeclared (first use in this function)
- 327 | , NULL);
- | ^~~~
- ../libraries/hal_drivers/drv_usart.c:20:1: note: 'NULL' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'?
- 19 | #include <drv_log.h>
- +++ |+#include <stddef.h>
- 20 |
- ../libraries/hal_drivers/drv_usart.c:327:42: note: each undeclared identifier is reported only once for each function it appears in
- 327 | , NULL);
- |
- ^~~~
复制代码
大意是:uint8_t NULL 未定义
解决方法:
在出错的文件里增加头文件(添加在drv_common.h可一次性解决)
- #include <stdint.h>
- #include <stddef.h>
复制代码
重新编译成功
- ........
- text data bss dec hex filename
- 140572 0 78188 218760 35688 rtthread.elf
- sh ../pre_build.sh
- riscv32-elf-xmaker -b rtthread.xm
- CODE SIZE: 147 KB
- save file "rtthread.dcf" successful
- riscv32-elf-xmaker -b download.xm
- 18:39:02 Build Finished. 0 errors, 0 warnings. (took 7s.301ms)
复制代码
|
+10
|