Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__cplusplus macro is not properly evaluated #2595

Closed
graph opened this issue Oct 2, 2018 · 2 comments
Closed

__cplusplus macro is not properly evaluated #2595

graph opened this issue Oct 2, 2018 · 2 comments
Assignees
Labels
Feature Request fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Milestone

Comments

@graph
Copy link

graph commented Oct 2, 2018

Type: LanguageService

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.17134.0",
            "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/Hostx64/x64/cl.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "msvc-x64",
            "compileCommands": "${workspaceFolder}/build/release/compile_commands.json"
        }
    ],
    "version": 4
}

Describe the bug

  • OS and Version: Windows 10

  • VS Code Version:
    Version: 1.29.0-exploration (user setup)
    Commit: f28f62c944c3f72b8c03deaff6f98ea3741ca677
    Date: 2018-10-02T05:46:41.453Z
    Electron: 3.0.2
    Chrome: 66.0.3359.181
    Node.js: 10.2.0
    V8: 6.6.346.32
    Architecture: x64

  • C/C++ Extension Version: 0.19.0

To Reproduce
have a c++ file with this code and above c_cpp_properties.json:

#pragma once

#ifdef __cplusplus
#if __cplusplus < 201402L
#error "C++14 or higher is required"
#endif
#endif

The plugin reports an error that C++14 or higher is required

@graph graph changed the title C++14 or higher required even though I specified c++17 __cplusplus macro is not properly evaluated Oct 2, 2018
@bobbrow
Copy link
Member

bobbrow commented Oct 2, 2018

Issue #2248 and https://blogs.msdn.microsoft.com/vcblog/2018/04/09/msvc-now-correctly-reports-__cplusplus/ have some more background on this issue.

Short story is that this was actually the expected behavior until earlier this year when /Zc:__cplusplus support was added to cl.exe. I think it was a mistake to close #2248 and we should use this issue to track adding support for this in IntelliSense.

@bobbrow bobbrow added this to the On Deck milestone Oct 2, 2018
@bobbrow bobbrow modified the milestones: On Deck, 1.0.0 Feb 5, 2020
@bobbrow bobbrow modified the milestones: 0.27.0, 1.0 Mar 12, 2020
@bobbrow bobbrow modified the milestones: 0.28.0, 0.29.0 May 1, 2020
@bobbrow bobbrow modified the milestones: 0.29.0, 0.30.0 Jul 7, 2020
@elahehrashedi elahehrashedi added the fixed Check the Milestone for the release in which the fix is or will be available. label Aug 27, 2020
@sean-mcmanus
Copy link
Contributor

Support for /Zc:__cplusplus in compilerArgs was added with https://github.com/microsoft/vscode-cpptools/releases/tag/0.30.0-insiders4 .

@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature Request fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Projects
None yet
Development

No branches or pull requests

4 participants