-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Comments
Forgot to add: CMakeLists.txtcmake_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"
}
] |
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? |
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. |
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). |
C++17 headers should work on Windows now with 0.17.1. |
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](https://user-images.githubusercontent.com/9763499/39964826-59a2afc2-568d-11e8-9e20-d8a361a438ca.png)
![image](https://user-images.githubusercontent.com/9763499/39964898-cb39ce4e-568e-11e8-83d6-9f5331156e2a.png)
The only compiler I have installed is latest 15.8-preview-1. Nothing can pick up anything else.
settings.json
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
The text was updated successfully, but these errors were encountered: