Hi,
It seems the problem is that main.h is included by stm32f7xx_hal_conf.h, itself included by stm32f7xx_hal.h (see the error message above) and that it includes stm32f769i_discovery.h which needs types that are defined by (possibly indirectly) by stm32f7xx_hal.h but after it includes main.h (which is probably expected to parameterize it).
So in main in the first case include files are:
- stm32f7xx_hal.h
- stm32f7xx_hal_conf.h
- main.h
- stm32f7xx_hal_conf.h
- stm32f769i_discovery.h
so when this last file was included, stm32f7xx_hal.h was fully parsed and all works well, while in the second case include files are:
- stm32f7xx_hal.h
- stm32f7xx_hal_conf.h
- main.h
- stm32f769i_discovery.h
- main.h
- stm32f7xx_hal_conf.h
and it does not work because, when stm32f769i_discovery.h is included, stm32f7xx_hal.h and stm32f7xx_hal_conf.h are not yet fully included...
There’s no simple cure for that as multiple-inclusion prevention will not permit to include stm32f7xx_hal.h from main.h (it will be skipped as you are already in the process of including it, altough not yet fully). The best would be to place all your application-specific include files in a new include file (say app.h) containing, for example#ifndef __APP_H #define __APP_H #include "stm32f7xx_hal.h" #include "cmsis_os.h" #include "stm32f769i_discovery.h" #include "stm32f769i_discovery_lcd.h" #include "stm32f769i_discovery_sdram.h" #include "stm32f769i_discovery_ts.h" #endif /* __APP_H */and just have in main.c
#include "stm32f7xx_hal.h" #include "cmsis_os.h" #include "main.h" /* USER CODE BEGIN Includes main.c*/ #include "app.h" /* USER CODE END Includes */
while main.h is left untouched (that is without any user includes).
Hope this helps,
Bernard (Ac6)
PS: To format code just place it between {CODE()} and {CODE}