Skip to content

How to solve the files generated by CubeMX There are many undefined in VSCODE. #2902

@vrxiaochouyu

Description

@vrxiaochouyu

Type: LanguageService

Describe the bug

  • OS and Version:win10 64
  • VS Code Version:1.23.0
  • C/C++ Extension Version:0.20.1

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
error01

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?
#include "stdint.h"
#include "core_cm0.h"
#include "stm32f103xb.h"

3,Due to the above problems, it may cause false reporting elsewhere.
expected a ')'
expected a ';'
123123
123124

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 <stdint.h> file path is still in VS2017.

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 "" has no field "UsbClockSelection"
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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions