0

I have some functions that refer to GPIO_TypeDef struct from STM32_HAL library and in Keil I recieve no errors in compilation, but VSCode marks it as "unknown identificator" error. I fixed it with adding

#include "stm32f103xe.h"

to main.hand both Keil and VScode now take it with no problems, but maybe I had to change something in VSCode settings to fix that problem.

lazba
  • 129
  • 9
  • What you have there is an Intellisense error. Think of Intellisense as an imperfect compiler that's allowed to make mistakes in order to deliver rapid feedback. In this case, though, the Keil build tools may be playing fun games and automatically including target system headers for you that VSCode knows nothing about. – user4581301 Feb 01 '22 at 20:25
  • But `stm32f103xe.h` is presented in VSCode `includePath` (as other project files do too, as I opened the root folder of the project) – lazba Feb 01 '22 at 20:31
  • and that's how Intellisence works after the code includes stm32f103xe.h, but before that it doesn't know it needs to include the header. No include directive in the code, and VSCode's not going to look at the header even if you point VSCode at the folder containing the header. There could be thousands of different target headers in there. It's not going to waste time parsing all of them. – user4581301 Feb 01 '22 at 20:35
  • I made some a research and found, that there are multiple ways this file IS included in main. For example: stm32f1xx.h->stm32f1xx_hal_def.h->stm32f1xx_hal_uart.h->stm32f1xx_hal_conf.h->stm32f1xx_hal.h->main.h so I don't know what's wrong with VSCode – lazba Feb 01 '22 at 20:51
  • 1
    Looks like we may be back to Intellisense isn't perfect. – user4581301 Feb 01 '22 at 21:06

1 Answers1

0

I found answer in CubeIDE directives. Add theese to C_Cpp.default.defines (You can simply do this through Settings->Extensions->C/C++->Defines)

__CC_ARM
STM32F1xx
USE_HAL_DRIVER
DEBUG
lazba
  • 129
  • 9