你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

在main.h中使用uint8_t 报错

[复制链接]
qutt_ 提问时间:2024-3-25 17:39 / 未解决
![image.png](data/attachment/forum/202403/25/173518mdyuub6d8uj66dtl.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/300 "image.png")
image.png
收藏 评论4 发布时间:2024-3-25 17:39

举报

4个回答
qutt_ 回答时间:2024-3-25 17:42:09

image.png

qutt_ 回答时间:2024-3-25 17:43:02

显示如下报错

D:/stm32cubeide/STM32CubeIDE_1.14.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Core/Src/gpio.o:D:/stm32cubeide/L431_RTOS/Debug/../Core/Inc/main.h:42: multiple definition of `u_buf'; ./Core/Src/freertos.o:D:/stm32cubeide/L431_RTOS/Debug/../Core/Inc/main.h:42: first defined here

D:/stm32cubeide/STM32CubeIDE_1.14.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Core/Src/main.o:D:/stm32cubeide/L431_RTOS/Debug/../Core/Inc/main.h:42: multiple definition of `u_buf'; ./Core/Src/freertos.o:D:/stm32cubeide/L431_RTOS/Debug/../Core/Inc/main.h:42: first defined here

D:/stm32cubeide/STM32CubeIDE_1.14.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Core/Src/stm32l4xx_hal_msp.o:D:/stm32cubeide/L431_RTOS/Debug/../Core/Inc/main.h:42: multiple definition of `u_buf'; ./Core/Src/freertos.o:D:/stm32cubeide/L431_RTOS/Debug/../Core/Inc/main.h:42: first defined here

D:/stm32cubeide/STM32CubeIDE_1.14.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Core/Src/stm32l4xx_it.o:D:/stm32cubeide/L431_RTOS/Debug/../Core/Inc/main.h:42: multiple definition of `u_buf'; ./Core/Src/freertos.o:D:/stm32cubeide/L431_RTOS/Debug/../Core/Inc/main.h:42: first defined here

D:/stm32cubeide/STM32CubeIDE_1.14.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.win32_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Core/Src/usart.o:D:/stm32cubeide/L431_RTOS/Debug/../Core/Inc/main.h:42: multiple definition of `u_buf'; ./Core/Src/freertos.o:D:/stm32cubeide/L431_RTOS/Debug/../Core/Inc/main.h:42: first defined here

collect2.exe: error: ld returned 1 exit status

make: *** [makefile:68: L431_RTOS.elf] Error 1

废鱼 回答时间:2024-3-25 20:08:55

重复定义了,引用一次main.h就会定义一次,在main.h中,一般用户extern或者特殊的定义方式,防止重复定义。

知足- 回答时间:2024-3-26 15:01:26

建议看看C语言extern关键字的用法。

建议多读读HAL库源码,学学别人的代码结构。

关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版