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

IntelliSense fails to detect _HAS_CXX17 macro with compile_commands.json #1990

Closed
MathiasMagnus opened this issue May 13, 2018 · 5 comments
Closed
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Milestone

Comments

@MathiasMagnus
Copy link

IntelliSense doesn't pick up new filesystem types, because it does not detect the macro defined in the title. The same code lights up perfectly in big brother VS.
image
image
The only compiler I have installed is latest 15.8-preview-1. Nothing can pick up anything else.

settings.json

{
  // Controls if the explorer should ask for confirmation when deleting a file via the trash.
  "explorer.confirmDelete": false,

  // Specifies the icon theme used in the workbench or 'null' to not show any file icons.
  "workbench.iconTheme": "material-icon-theme",

  // The path to CMake generator executable
  "cmake.cmakePath": "C:/Program Files/CMake/bin/cmake.exe",

  // Additional arguments to pass to CMake when configuring
  "cmake.configureArgs": [
    "-DCMAKE_MODULE_PATH=C:/Users/mnagy/Source/Repos/vcpkg/installed/x64-windows/share/sfml"
  ],

  // The directory where CMake build files will go
  "cmake.buildDirectory": "${workspaceRoot}/.vscode/cmake/build",

  // The value to use in a configuration if "compileCommands" is either not specified, or set to "${default}".
  "C_Cpp.default.compileCommands": "${workspaceRoot}/.vscode/cmake/build/compile_commands.json",
    
  // Controls the IntelliSense provider. "Tag Parser" provides "fuzzy" results that are not context-aware. "Default" provides context-aware results and is in preview mode - member list, hover tooltips, and error squiggles are currently implemented. Features not yet implemented in the new default engine will use the tag parser engine instead.
  "C_Cpp.intelliSenseEngineFallback": "Disabled",

  // Specifies the full path to a PowerShell executable. Changes the installation of PowerShell used for language and debugging services.
  "powershell.powerShellExePath": "C:/Kellekek/Microsoft/PowerShell/6.1.0-preview2/pwsh.exe"
}

CMake version is 3.11.1, CMake Tools version is 0.11.1, CppTools version is 0.17.0, VS Code version is 1.23.1

@MathiasMagnus
Copy link
Author

Forgot to add:

CMakeLists.txt

cmake_minimum_required(VERSION 3.8.0)

project(FileIO LANGUAGES CXX)

add_executable(Cpp17 17.cpp)

set_target_properties(Cpp17 PROPERTIES CXX_STANDARD 17
                                       CXX_STANDARD_REQUIRED ON
                                       CXX_EXTENSIONS OFF)

compile_commands.json

[
{
  "directory": "c:/users/mnagy/source/fileio/.vscode/cmake/build",
  "command": "C:\\Kellekek\\MICROS~1\\VISUAL~1\\Preview\\VC\\Tools\\MSVC\\1414~1.264\\bin\\Hostx64\\x64\\cl.exe  /nologo /TP   /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1   -std:c++17 /FoCMakeFiles\\Cpp17.dir\\17.cpp.obj /FdTARGET_COMPILE_PDB /FS -c C:\\Users\\mnagy\\Source\\FileIO\\17.cpp",
  "file": "C:/Users/mnagy/Source/FileIO/17.cpp"
}
]

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented May 14, 2018

Yeah, investigating the _HAS_CXX17/c++latest/_MSC_VER is on our TODO list (we may need to query the cl.exe compiler for that define, not sure yet...cl.exe doesn't allow the same querying mechanism as gcc/clang and it only defines a small number of defines so it's been delayed). Adding _HAS_CXX17 to the defines lists works without the compile_commands.json. Are you able to add that define to your CMakeLists.txt or settings?

@MathiasMagnus
Copy link
Author

Well, I could. The semester is coming to and end soon and I will receive a DUMP of C++ homework and I'd hate to either patch every ones scripts and/or create workplace settings to add this define. If I add the define as user setting, I have no idea what's going to happen with the MSVC STL if I manually add a language version define that should not exist. Most likely a lot of C++17 language features will activate that are not valid C++11/14. (I know some stuff are active nontheless for this very purpose, even though it's not valid, but still… it feels very wrong.)

So yes, I can patch things on my end (with definitely non-zero effort), but it's not the ultimate solution.

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented May 15, 2018

It turns out we weren't passing the correct flags to our compiler, causing it to not use the correct C++17 behavior (i.e. _MSC_LANG wasn't the correct version). Our pending 0.17.1 update should have a fix for this. So all you should have to do is set the cppStandard to c++17 (to have filesystem) or c++14 (to not have it recognized). BTW, just defining _HAS_CXX17 may cause issues, because our compiler wasn't being configured to fully support C++17.

UPDATE: But if you wanted the language version to be determined by compile_commands.json, we have #1755 tracking that (we haven't gotten much feedback requests for that though).

@sean-mcmanus sean-mcmanus added bug Language Service fixed Check the Milestone for the release in which the fix is or will be available. labels May 15, 2018
@sean-mcmanus sean-mcmanus added this to the 0.17.1 milestone May 15, 2018
@sean-mcmanus
Copy link
Contributor

C++17 headers should work on Windows now with 0.17.1.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug 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

2 participants