vscode-cmake-tools
vscode-cmake-tools copied to clipboard
IntelliSense complains about standard types when using precompiled headers
Brief Issue Summary
IntelliSense starts to complain about all standard things when I'm using target_precompile_headers()
, e.g. std::size_t: "namespace "std" has no member "size_t""
. The project itself builds just fine.
Code structure:
//./project/src/common.h
#include <vector>
//etc.
//./project/src/main.cpp
#include "common.h"
//use std::vector...
CMake structure:
# ./project/CMakeLists.txt:
# some global settings like project(), etc.
add_subdirectory(src)
# ./project/src/CMakeLists.txt
add_executable(project)
target_sources(project
PRIVATE
main.cpp
common.h)
target_precompile_headers(project
PRIVATE
"common.h"
)
Without target_precompile_headers()
everything is OK.
Platform and Versions
- Operating System: Ubuntu 18.04
- CMake Version: 3.16
- VSCode Version: 1.43.2
- CMake Tools Extension Version: 1.3.1
- Compiler/Toolchain: GCC 9.2.1
I do not reproduce this and I made sure I installed recent cmake and gcc. It could help if you can share a standalone small repro and its settings.
Here it is: https://github.com/OleksandrKvl/vscode_pch_test
Don't pay attention to key shortcuts at the bottom of the main.cpp, that's my local bindings.
The only thing I changed in global CMake settings is "cmake.buildDirectory": "${workspaceFolder}/build_${buildType}"
, I put it into the local settings.json file to preserve this small detail.
The strange thing is that even if I remove common.h from main.cpp and include iostream and vector directly, error is still there. It's gone only when I remove target_precompile_headers(). And error occurs only after build, for example: no pch -> no errors -> enable pch -> still no errors -> rebuild -> errors appear now. Sometimes they don't appear immediately, only after several seconds after build.
I reproduce now, thanks for the small project.
Hi all, Meanwhile are there any work-arounds to this issue?
@andreeis While you guys are fixing it, are there any workarounds in the meantime? The extension is pretty much unusable for me because of this. Thanks in advance.
@ItsSunnyMonster, I don't reproduce this anymore and the project linked above is no longer accessible. Can you share more information about your project and also share the result of running CMake: Log Diagnostics
and C/C++: Log Diagnostics
when the file with the red squiggles is open?
I believe it was fixed in 1.11.25 with this PR where we started forwarding the compiler options to cpptools for parsing instead of doing it ourselves: https://github.com/microsoft/vscode-cmake-tools/pull/2563
This issue has been closed automatically because it needs more information and has not had recent activity.