Skip to content

[Bug]: compile_macros.h causes many false errors from clangd for C++ codes #625

Description

@chentang16

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

In CMSIS solution v1.68, compiler toolchain specific predefined macros are added to compile_macros.h and a .clangd file is generated to include this compile_macros.h when (re)loading a project.
However, macros defined in this compile_macros.h would cause many false syntax checking errors from clangd for C++ codes.

e.g. For some C++17 features testing code in the attached project,
When using AC6, the macros in the generated compile_macros.h are not sufficient. Adding an additional -D__ARMCOMPILER_LIBCXX=1 can resolve these false errors. (However, one user's real-world C++ project would still have many false errors for template classes and template functions.)
Image

When using CLANG, the macros in the generated compile_macros.h would cause many false errors. Removing the entire compile_macros.h include can resolve all false errors. One user's opinion is that this compile_macros.h is completely unnecessary when using CLANG.
Image

Since for now the compile_macros.h is global to entire project, instead of individually for each file, some macros like __STDC_VERSION__ do cause issues for C++ code for a project mixed with C and C++ code.

Blinky_AC6.zip
Blinky_CLANG.zip

Expected Behavior

No response

Steps To Reproduce

No response

Affected tools

  • cbridge
  • cbuild
  • cbuild2cmake
  • cpackget
  • csolution
  • packchk
  • svdconv
  • vidx2pidx

Affected operating systems

  • all
  • Windows amd64
  • Windows arm64
  • Linux amd64
  • Linux arm64
  • MacOS amd64
  • MacOS arm64

Environment

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

No fields configured for Bug.

Projects

Status
Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions