microsoft / microsoft/vscode-cpptools

"Expected an expression" error on a "#include" string

Open
#8,244 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug type: Language Service

Describe the bug

  • OS and Version: doesn't matter
  • VS Code Version: doesn't matter
  • C/C++ Extension Version: v1.6.0
  • Other extensions you installed (and if the issue persists after disabling them): doesn't matter
  • If using SSH remote, specify OS of remote machine: doesn't matter
  • A clear and concise description of what the bug is, including information about the workspace (i.e. is the workspace a single project or multiple projects, size of the project, etc).

This should be a valid c++ syntax:

(not sure if this has been reported before)

constexpr char STA_SSID[] =
#include "ssid.txt"
    ;

Expected behavior

No error reported

Screenshots

image

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

Start by reproducing the shown C++ snippet in the C++ language service and inspect the diagnostic produced at the #include line. Trace how the language service handles an include used as the initializer for a constexpr char array. Done means the valid snippet produces no “Expected an expression” error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.