Giter Site home page Giter Site logo

Comments (5)

v-frankwang avatar v-frankwang commented on July 20, 2024 1

@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:

image

image

from vscode-cmake-tools.

kokostek avatar kokostek commented on July 20, 2024 1

@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.

v-frankwang avatar v-frankwang commented on July 20, 2024

@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.

kokostek avatar kokostek commented on July 20, 2024

@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.

jophippe avatar jophippe commented on July 20, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.