Type: LanguageService
Describe the bug
1,The EWARM project created with CubeMX, opened with VSCODE, has many mistakes.
identifier "uint32_t" is undefined
identifier "SysTick" is undefined
identifier "GPIOA" is undefined
expected a ')'
identifier "GPIO_CRL_MODE0" is undefined
2,Add the following #include to resolve. But all files have this problem, do I have to add one by one? What is the fundamental solution?
3,Due to the above problems, it may cause false reporting elsewhere.
expected a ')'
expected a ';'
4,update:A lot of errors were solved by adding a include path to c_cpp_properties.json .
But there are still a few mistakes.
variable "uint32_t" is not a type name
identifier "__IO" is undefined
identifier "SysTick_IRQn" is undefined
and so on
5,update:c_cpp_properties.json "defines" add "__CC_ARM" Solved the problem of"uint32_t"in main.c.
But other driver files still have such errors.
such as system_stm32f1xx.c, usbd_conf.c, stm32f1xx_hal_rcc..h,stm32f1xx_hal_dma.h
6,update: I found that although I added IAR paths, the
7,update: I found that if I open all the project files, the number of errors will be much reduced!!
There are only 4 errors now.
'main.h' file not found //This problem sometimes appears sometimes does not appear
identifier "RCC_PERIPHCLK_USB" is undefined
struct "
identifier "RCC_USBCLKSOURCE_PLL_DIV1_5" is undefined//TThese three questions are all they can find definitions, but still report an error. #include "stm32f1xx_hal_rcc_ex.h" No error, stm32f1xx_hal_rcc_ex.h not error too.
By the way, this is the first time that I have used VSCODE to write STM32 project.
thank you!
2,Add the following #include to resolve. But all files have this problem, do I have to add one by one? What is the fundamental solution?
I recommend using the "forcedInclude" property in c_cpp_properties.json. [reference]
Create a header file that contains all of the prerequisite includes and then force include it into all of your files. My (limited) experience with these IoT projects is that the IDEs that support them are doing some "magic" to make your source files compile and our extension doesn't know how to do that by default.
2,Add the following #include to resolve. But all files have this problem, do I have to add one by one? What is the fundamental solution?
I recommend using the
"forcedInclude"property inc_cpp_properties.json. [reference]
Create a header file that contains all of the prerequisite includes and then force include it into all of your files. My (limited) experience with these IoT projects is that the IDEs that support them are doing some "magic" to make your source files compile and our extension doesn't know how to do that by default.
Thank you for your reply. This is very useful.
I ran into a similar problem. Tried to do the forcedInclude fix, but ran into the issue that Intellisense warned me that certain .h files could not be found.
Turned out that STM32CubeMX does not automatically uncomment the device I use in {projectRootFolder}/Drivers/CMSIS/Device/ST/{device family}/{device family}.h (for me that was ./Drivers/CMSIS/Device/ST/STM32L0xx/stm32l0xx.h)
When you open that file, somewhere around line 60 there's a list of devices, uncomment the line listing the device you use and you should be good to go. Just find the line that says /* Uncomment the line below according to the target STM32 device used in your
application
*/ and look below that.
I ran into a similar problem. Tried to do the forcedInclude fix, but ran into the issue that Intellisense warned me that certain .h files could not be found.
Turned out that STM32CubeMX does not automatically uncomment the device I use in
{projectRootFolder}/Drivers/CMSIS/Device/ST/{device family}/{device family}.h(for me that was./Drivers/CMSIS/Device/ST/STM32L0xx/stm32l0xx.h)When you open that file, somewhere around line 60 there's a list of devices, uncomment the line listing the device you use and you should be good to go. Just find the line that says
/* Uncomment the line below according to the target STM32 device used in your application */and look below that.
This fixed the issue for me.
Thanks a lot !
I ran into a similar problem. Tried to do the forcedInclude fix, but ran into the issue that Intellisense warned me that certain .h files could not be found.
Turned out that STM32CubeMX does not automatically uncomment the device I use in
{projectRootFolder}/Drivers/CMSIS/Device/ST/{device family}/{device family}.h(for me that was./Drivers/CMSIS/Device/ST/STM32L0xx/stm32l0xx.h)When you open that file, somewhere around line 60 there's a list of devices, uncomment the line listing the device you use and you should be good to go. Just find the line that says
/* Uncomment the line below according to the target STM32 device used in your application */and look below that.
Thanks for the tip. I did not find what exactly I should uncomment, and I did not really want to edit system files. However, I added "_STM32F030x6_" to the "defines" property in c_cpp_properties.json and the problem is gone.
I ran into a similar problem. Tried to do the forcedInclude fix, but ran into the issue that Intellisense warned me that certain .h files could not be found.
Turned out that STM32CubeMX does not automatically uncomment the device I use in{projectRootFolder}/Drivers/CMSIS/Device/ST/{device family}/{device family}.h(for me that was./Drivers/CMSIS/Device/ST/STM32L0xx/stm32l0xx.h)
When you open that file, somewhere around line 60 there's a list of devices, uncomment the line listing the device you use and you should be good to go. Just find the line that says/* Uncomment the line below according to the target STM32 device used in your application */and look below that.Thanks for the tip. I did not find what exactly I should uncomment, and I did not really want to edit system files. However, I added "_STM32F030x6_" to the "defines" property in
c_cpp_properties.jsonand the problem is gone.
You're right. I ran into the same problem and what you did set me thinking.
_c_cpp_properties.json_ file should match the makefile generated by STM32CubeMX, which, indead, uses some define flags. In my case there was USE_HAL_DRIVER and STM32F401xE. By adding these two to the "defines" property of _c_cpp_properties.json_ it solves the problem.
This issue appears to have been resolved.
Most helpful comment
I ran into a similar problem. Tried to do the forcedInclude fix, but ran into the issue that Intellisense warned me that certain .h files could not be found.
Turned out that STM32CubeMX does not automatically uncomment the device I use in
{projectRootFolder}/Drivers/CMSIS/Device/ST/{device family}/{device family}.h(for me that was./Drivers/CMSIS/Device/ST/STM32L0xx/stm32l0xx.h)When you open that file, somewhere around line 60 there's a list of devices, uncomment the line listing the device you use and you should be good to go. Just find the line that says
/* Uncomment the line below according to the target STM32 device used in your application */and look below that.