Comments (5)
@gcampbell-msft @kokostek The user's problem is that cmake uses the vs2022 generator, but IntelliSense in vscode searches for header files in the vs2017 include directory. I reproduced the issue raised by the user and here are the steps to reproduce this issue
Repro steps:
1. Create a folder named test and open it with vscode.
2. Create a CMakeLists.txt file and add the following code:
cmake_minimum_required(VERSION 3.12)
project(VSCodeCMakeTest)
add_executable(main main.cpp)
target_compile_features(main PUBLIC cxx_std_20)
4. Create a main.cpp file and add the following code:
#include <cstdio>
#include <ranges>
int main(int argc, const char* argv[])
{
return 0;
}
6. Create a CMakePreset,json file and add the following code:
{
"version": 3,
"configurePresets": [
{
"name": "win-x64-debug",
"description": "Target Windows with the Visual Studio development environment.",
"generator": "Visual Studio 17 2022",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe",
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CONFIGURATION_TYPES": "Debug"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"architecture": {
"value": "x64",
"strategy": "set"
}
}
]
}
8. Run command:"CMake:Configure"
9. Select "configurePresets":"win-x64-debug"
Actual result:
from vscode-cmake-tools.
@jophippe Thanks for the update! Yes, seems like it is fixed now with pre-release cpptools. Though I had to delete cache and reconfigure to make error squiggles go away.
from vscode-cmake-tools.
@gcampbell-msft I think the user this problem is because, #include this header file is introduced in c++20 standard, but visual studio2017 doesn't support C++20 standard, so that's why this problem is occurring, even if you add target_compile_features in CMakeLists file ( main PUBLIC cxx_std_20) in the CMakeLists file, it should not make the compiler to support C++20, I don't know if I understand correctly, can you give me some suggestions?
from vscode-cmake-tools.
@v-frankwang, not quite. I have vs2022 installed, and cmake uses vs2022 generator and configure/build runs successfully. The problem is that the IntelliSense in vscode searches for headers in vs2017 include dir for some unknown reason, and shows false-positive error squiggles.
from vscode-cmake-tools.
@kokostek Looks like this is most likely a bug in cpptools: microsoft/vscode-cpptools#12293
It should be fixed in cpptools version 1.21.0, which is available in pre-release. You can switch to the pre-release version on the cpptools extension page. Please let us know if that fixes your issue.
Thanks!
from vscode-cmake-tools.
Related Issues (20)
- project outline doesn't show header files if grpc src (.cc) is added HOT 1
- Why CMAKE_BUILD_TYPE is always Debug? HOT 16
- Why not add a feature to set launch args and debug args just in the GUI tool? HOT 1
- How come my build presets don't show up in the Build Preset List? HOT 3
- Source and build directories should be configurable per kit
- CMake Error: Not a file: G:/dev/cmaketest HOT 4
- Release target, Debug output HOT 10
- CMake Tools cause probleme HOT 2
- `CMakeUserPresets.json` not visible in PROJECT OUTLINE HOT 1
- I dont now what is this error HOT 2
- Old project name present in Project Outline after project was renamed HOT 3
- Please configure CMake to build and run the tests I'm running HOT 1
- Test Discovery and Test results not working due to Path problem HOT 2
- Feature Request: Make `Compile active file` a first-class citizen
- Project Outline Does Not Show included cmake files HOT 1
- Custom visualStudio kit PATH setting is ineffective HOT 2
- When a compiler is upgraded, the older version of the compiler is not removed from the toolkit list. HOT 1
- usepresets context is not set after manually creating a cmakepresets.json HOT 3
- The CMake: Select a kit command does not work the first time you click on it.
- The code in the main.cpp file generated using CMake: Quick start is C code HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-cmake-tools.