microsoft / microsoft/vscode-cpptools

Extension overrides C/C++ standard settings from configuration

Open
#12,451 1 comment 0 reactions 1 assignee View on GitHub

@sean-mcmanus is already working on this.

Since Jul 8, 2024.

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

Description

Environment
  • OS and Version: Windows 10 22H2
  • VS Code Version: 1.91.0
  • C/C++ Extension Version: 1.20.5
Bug Summary and Steps to Reproduce

Bug Summary:
Due to current automatic behavior, it is impossible to use intellisense with cl.exe on older projects that correctly compile with CL.
Extension always overrides cStandard and cppStandard settings based on compiler path for cl.exe if flags are given without /std.
The default settings without flags are C89 and C++14 - at least for Visual Studio 2022 CL 19.40.33811.
There is no /std flag for standards older than C11 and C++14, but the compiler accepts these without a flag.

Steps to reproduce:

  1. Create c_cpp_properties.json with selected cStandard and cppStandard older than C++17/C17.
  2. Note messages like:
    For C++ source files, the cppStandard was changed from "c++03" to "c++17" based on compiler args and querying compilerPath
    For C source files, the cStandard was changed from "c89" to "c17" based on compiler args and querying compilerPath

Expected behavior:
If any of /permissive, /Zc or /Ze are provided in arguments, the override is not applied.
OPTIONALLY:
Plugin checks the compiler version by running cl.exe and sets the override based on compiler version.
This would typically be C89/C++14, unless it changes later for a newer Microsoft compiler.

Configuration and Logs
{
    "configurations": [
        {
            "name": "C89/C++03 VS2022",
            "intelliSenseMode": "windows-msvc-x64",
            "compilerPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.40.33807\\bin\\Hostx64\\x64\\cl.exe",
            "compilerArgs": [
                "/Od",
                "/permissive"
            ],
            "cppStandard": "c++03",
            "cStandard": "c89",
            "windowsSdkVersion": "10.0.19041.0"
        }
    ],
    "version": 4
}
Other Extensions

No response

Additional context

No response

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.