microsoft / microsoft/vscode-cpptools

X-Macro expansion false error.

Open
#14,435 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Language Service verified Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: Debian GNU/Linux 13 Trixie
  • VS Code Version: 1.119.0
  • C/C++ Extension Version: 1.32.2
Bug Summary and Steps to Reproduce

Bug Summary:
False error with X-Macros.

Steps to reproduce:

  1. Create a new C file colors.def for example with this content :
COLOR(RED)
COLOR(GREEN)
COLOR(BLUE)
  1. Create another C file like main.c with this content :
enum colors_t {
#define COLOR(NAME) NAME,
#include "colors.def"
#undef COLOR
};
  1. See the false error "expected an identifier" but compilation works perfectly.

Expected behavior:
No false error as the macro should expand and complete the enum.

Configuration and Logs
{
    "configurations": [
        {
            "name": "Default",
        }
    ],
    "version": 4
}
Other Extensions

Issue still persist after disabling any other extensions.

Additional context

This is not a fatal error since it is only visual but it is a problem in intellisense that shows up error even if there are not...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the diagnostic with the two files named in the report, colors.def and main.c, using the shown X-macro pattern. Trace how IntelliSense parses the included macro expansion and identify why it reports “expected an identifier”; done means the false diagnostic disappears while the example continues to compile successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.