2022-03-21 07:54 AM
Hello,
I am creating the header and source file according to the IC. Two Ic I interface and created its header file particular ,but when I tried to add header file in second source file I getting this and errors. I am unable to understand why its errors are come There are 2 core ,core M4 and M7.In both core the IO.h are defined when I tried to add this file to any source files it through errors.
make -j4 all
arm-none-eabi-gcc "../Core/Src/Temp.c" -mcpu=cortex-m4 -std=gnu11 -g3 -DDEBUG -DCORE_CM4 -DUSE_HAL_DRIVER -DSTM32H745xx -c -I../Core/Inc -I../../Drivers/STM32H7xx_HAL_Driver/Inc -I../../Drivers/STM32H7xx_HAL_Driver/Inc/Legacy -I../../Drivers/CMSIS/Device/ST/STM32H7xx/Include -I../../Drivers/CMSIS/Include -I../USB_DEVICE/App -I../USB_DEVICE/Target -I../../Middlewares/ST/STM32_USB_Device_Library/Core/Inc -I../../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Core/Src/Temp.d" -MT"Core/Src/Temp.o" --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -o "Core/Src/Temp.o"
arm-none-eabi-gcc -o "PL_REV1_CM4.elf" @"objects.list" -mcpu=cortex-m4 -T"D:\Project\PL_REV1\CM4\STM32H745IIKX_FLASH.ld" --specs=nosys.specs -Wl,-Map="PL_REV1_CM4.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
c:\st\stm32cubeide_1.8.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: ./Core/Src/Temp.o:D:/Project/PL_REV1/CM4/Debug/../Core/Inc/IO.h:19: multiple definition of `PCAL6524_ADDRESS_0'; ./Core/Src/IO.o:D:/Project/PL_REV1/CM4/Debug/../Core/Inc/IO.h:19: first defined here
c:\st\stm32cubeide_1.8.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: ./Core/Src/Temp.o:D:/Project/PL_REV1/CM4/Debug/../Core/Inc/IO.h:20: multiple definition of `PCAL6524_ADDRESS_1'; ./Core/Src/IO.o:D:/Project/PL_REV1/CM4/Debug/../Core/Inc/IO.h:20: first defined here
c:\st\stm32cubeide_1.8.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: ./Core/Src/Temp.o:D:/Project/PL_REV1/CM4/Debug/../Core/Inc/IO.h:21: multiple definition of `PCAL6524_ADDRESS_2'; ./Core/Src/IO.o:D:/Project/PL_REV1/CM4/Debug/../Core/Inc/IO.h:21: first defined here
c:\st\stm32cubeide_1.8.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: ./Core/Src/Temp.o:D:/Project/PL_REV1/CM4/Debug/../Core/Inc/IO.h:22: multiple definition of `PCAL6524_ADDRESS_3'; ./Core/Src/IO.o:D:/Project/PL_REV1/CM4/Debug/../Core/Inc/IO.h:22: first defined here
c:\st\stm32cubeide_1.8.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: ./Core/Src/Temp.o:D:/Project/PL_REV1/CM4/Debug/../Core/Inc/IO.h:28: multiple definition of `PCAL6524_INPUT_PORT_0'; ./Core/Src/IO.o:D:/Project/PL_REV1/CM4/Debug/../Core/Inc/IO.h:28: first defined here
c:\st\stm32cubeide_1.8.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.9-2020-q2-update.win32_2.0.0.202105311346\tools\arm-none-eabi\bin\ld.exe: ./Core/Src/Temp.o:D:/Project/PL_REV1/CM4/Debug/../Core/Inc/IO.h:29: multiple definition of `PCAL6524_INPUT_PORT_1';
2022-03-21 09:13 AM
No, what you're probably doing is defining variable(s) in an include file, which is a no-no.
The include file should have prototypes and externs, and the functions and variables defined ONCE in a source file.
Include files should not have code in them.
IO.c and IO.h need to be worked on.
2022-03-21 08:52 PM
When I try to add IO.h in IO.c its working fime but when I try to add this file in main.c or temp.c it throw errors.I am sharing the the snap of my files, i am unable to understand why its erroe comes.
2022-03-21 09:26 PM
>> i am unable to understand why its error
It SPECIFICALLY tells you it's those variables you're defining as const.
Put those in IO.C, or use #define's or enum's
2022-03-21 09:41 PM
Thank you the error gets solve
2022-03-22 12:48 PM
Cube 1.9 introduces this error into many projects, because it changes the GCC compiler from v9 to v10.