2022-08-02 11:48 PM
09:32:54 **** Incremental Build of configuration Debug for project uart_deneme ****
make -j8 all
arm-none-eabi-gcc "../Core/Src/myHeader.c" -mcpu=cortex-m0 -std=gnu11 -g -DDEBUG -DUSE_HAL_DRIVER -DSTM32F072xB -c -I../Drivers/STM32F0xx_HAL_Driver/Inc -I../Drivers/CMSIS/Include -I../Core/Inc -I../Drivers/STM32F0xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32F0xx/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Core/Src/myHeader.d" -MT"Core/Src/myHeader.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Core/Src/myHeader.o"
In file included from ../Core/Src/myHeader.c:11:
../Core/Inc/myHeader.h:14:8: error: unknown type name 'I2C_HandleTypeDef'
14 | extern I2C_HandleTypeDef hi2c1;
| ^~~~~~~~~~~~~~~~~
../Core/Src/myHeader.c:32:29: error: conflicting types for 'hi2c1'
32 | extern I2C_HandleTypeDef hi2c1;
| ^~~~~
In file included from ../Core/Src/myHeader.c:11:
../Core/Inc/myHeader.h:14:26: note: previous declaration of 'hi2c1' was here
14 | extern I2C_HandleTypeDef hi2c1;
| ^~~~~
make: *** [Core/Src/subdir.mk:40: Core/Src/myHeader.o] Error 1
"make -j8 all" terminated with exit code 2. Build might be incomplete.
09:32:55 Build Failed. 3 errors, 0 warnings. (took 654ms)
2022-08-03 07:53 AM
The first error tells you all you need to know. Something is "unknown" (i.e. not defined). Find where that is defined (hint: somewhere in a .h file) and make sure that include file is included BEFORE you include "myHeader.h". Or, put that include at the top of "myHeader.h", but that gets in to almost religious arguments about how to organize and use include files.
2022-08-03 10:33 PM
error: unknown type name 'I2C_HandleTypeDef'
the file does not know that type and thus needs to include the i2c HAL .h file.
2022-08-04 12:05 AM
Look in your stm32f0xx_hal_conf.h file, make sure the I2C module is selected.
2022-08-04 01:23 AM
#include is to import multiple text slices in order, then compiler will crunch the glued together source text file.
If the includes are not in the right order, you may use a type defined later, and the compiler will fail because it read beginning to end, no bottom to top sweeping.