Vscode-cpptools: __cplusplus macro is not properly evaluated

Created on 2 Oct 2018  Â·  2Comments  Â·  Source: microsoft/vscode-cpptools

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

Feature Request Language Service fixed (release pending)

Most helpful comment

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.

All 2 comments

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.

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

Was this page helpful?
0 / 5 - 0 ratings