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 picks up wrong include path and shows false-positive error squiggles #3781

Closed
kokostek opened this issue May 20, 2024 · 5 comments
Assignees
Labels
bug a bug in the product Feature: configure
Milestone

Comments

@kokostek
Copy link

kokostek commented May 20, 2024

Brief Issue Summary

I have two Visual Studios installed on my PC: 2017 and 2022. CMake project build targets VS2022 by specifying "generator": "Visual Studio 17 2022" in CMakePresets.json.

IntelliSense reports errors when I try to include some standard header, which is available in VS2022, but not available in VS2017, like <ranges> for example:
image

In the mean time, project configures and builds just fine.

When I try to navigate to included file which is not highlighted by IntelliSense (i.e. <cstdio>), I end up in the VS2017 include directory, which is also not ok:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\include\cstdio

Project contents:

  • CMakeLists.txt:
cmake_minimum_required(VERSION 3.12)
project(VSCodeCMakeTest)
add_executable(main main.cpp)
target_compile_features(main PUBLIC cxx_std_20)
  • CMakePresets.json:
{
  "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"
      }
    }
  ]
}
  • main.cpp:
#include <cstdio>
#include <ranges>

int main(int argc, const char* argv[])
{
    return 0;
}

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.89.1",
  "cmtVersion": "1.18.39",
  "configurations": [
    {
      "folder": "c:\\vs\\VSCodeCmakeTest",
      "cmakeVersion": "3.27.0",
      "configured": true,
      "generator": "Visual Studio 17 2022",
      "usesPresets": true,
      "compilers": {
        "C": "cl.exe",
        "CXX": "cl.exe"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [
      "file:///c%3A/vs/VSCodeCmakeTest/main.cpp"
    ],
    "responses": [
      {
        "uri": "file:///c%3A/vs/VSCodeCmakeTest/main.cpp",
        "configuration": {
          "includePath": [],
          "defines": [],
          "compilerPath": "c:/program files/microsoft visual studio/2022/professional/vc/tools/msvc/14.39.33519/bin/hostx64/x64/cl.exe",
          "compilerArgs": [],
          "compilerFragments": [
            "/DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 -std:c++20"
          ]
        }
      }
    ],
    "partialMatches": [],
    "targetCount": 3,
    "executablesCount": 1,
    "librariesCount": 0,
    "targets": [
      {
        "name": "ALL_BUILD",
        "type": "UTILITY"
      },
      {
        "name": "ZERO_CHECK",
        "type": "UTILITY"
      },
      {
        "name": "main",
        "type": "EXECUTABLE"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": null
    }
  ]
}

Debug Log

[expand] expanding cmake
[main] Configuring project: VSCodeCmakeTest 
[main] Saving open files before configure/build
[driver] Removing C:/vs/VSCodeCmakeTest/build/win-x64-debug/CMakeCache.txt
[driver] Removing C:\vs\VSCodeCmakeTest\build\win-x64-debug\CMakeFiles
[expand] expanding C:/vs/VSCodeCmakeTest
[driver] Start configure 
[driver] Running pre-configure checks and steps
[expand] expanding C:/vs/VSCodeCmakeTest
[cmakefileapi-driver] Configuring using preset
[cmakefileapi-driver] Invoking CMake C:\Program Files\CMake\bin\cmake.EXE with arguments ["-DCMAKE_C_COMPILER=cl.exe","-DCMAKE_CXX_COMPILER=cl.exe","-DCMAKE_BUILD_TYPE=Debug","-DCMAKE_CONFIGURATION_TYPES=Debug","-DCMAKE_INSTALL_PREFIX=C:/vs/VSCodeCmakeTest/build/win-x64-debug","-SC:/vs/VSCodeCmakeTest","-BC:/vs/VSCodeCmakeTest/build/win-x64-debug","-G","Visual Studio 17 2022","-A","x64"]
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" -DCMAKE_C_COMPILER=cl.exe -DCMAKE_CXX_COMPILER=cl.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CONFIGURATION_TYPES=Debug -DCMAKE_INSTALL_PREFIX=C:/vs/VSCodeCmakeTest/build/win-x64-debug -SC:/vs/VSCodeCmakeTest -BC:/vs/VSCodeCmakeTest/build/win-x64-debug -G "Visual Studio 17 2022" -A x64
[proc]   with environment: {"ALLUSERSPROFILE":"C:\\ProgramData","APPDATA":"C:\\Users\\User\\AppData\\Roaming","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"1","CAMEXPERTDIR":"C:\\Program Files\\Teledyne DALSA\\Sapera\\CAMEXPERT","CHROME_CRASHPAD_PIPE_NAME":"\\\\.\\pipe\\crashpad_20424_GKCQVGIRKCAWPWTE","CLINK_DIR":"C:\\Program Files (x86)\\clink","COMPUTERNAME":"KOSTIK-2019","CUDA_PATH":"C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.8","CUDA_PATH_V11_3":"C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.3","CUDA_PATH_V11_8":"C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.8","CVB":"C:\\Program Files\\STEMMER IMAGING\\Common Vision Blox\\","CVBCONFIG":"C:\\ProgramData\\STEMMER IMAGING\\Common Vision Blox\\","CVBDATA":"C:\\ProgramData\\STEMMER IMAGING\\Common Vision Blox\\","CVGENICAM_REGISTRY":"C:\\ProgramData\\STEMMER IMAGING\\Common Vision Blox\\GenICam\\xml\\Registry","CXEXPLORER_DATA":"C:\\Users\\Public\\Documents\\Automation Technology GmbH","CXEXPLORER_HOME":"C:\\Program Files\\Automation Technology GmbH\\CXExplorer (64Bit)","CX_SDK_EXAMPLES":"C:\\Users\\Public\\Documents\\cxSupportPackage","CX_SDK_ROOT_64":"C:\\Program Files\\cxSupportPackage\\cxSDK","ComSpec":"C:\\WINDOWS\\system32\\cmd.exe","CommonProgramFiles":"C:\\Program Files\\Common Files","CommonProgramFiles(x86)":"C:\\Program Files (x86)\\Common Files","CommonProgramW6432":"C:\\Program Files\\Common Files","DriverData":"C:\\Windows\\System32\\Drivers\\DriverData","ELECTRON_RUN_AS_NODE":"1","FPS_BROWSER_APP_PROFILE_STRING":"Internet Explorer","FPS_BROWSER_USER_PROFILE_STRING":"Default","F_IA32_REDIST11":"C:\\Program Files (x86)\\Common Files\\Intel\\Shared Files\\fortran\\","GENICAM_CACHE_V2_1":"C:\\ProgramData\\GenICam\\xml\\cache","GENICAM_CACHE_V3_1":"C:\\ProgramData\\STEMMER IMAGING\\Common Vision Blox\\GenICam\\xml\\GenApi\\cache","GENICAM_CLPROTOCOL":"C:\\Program Files\\Teledyne DALSA\\Sapera\\GenICam_2_1\\CLProtocol","GENICAM_GENTL64_PATH":"C:\\Program Files\\STEMMER IMAGING\\Common Vision Blox\\GenICam\\bin\\win64_x64\\TLIs","GENICAM_LOG_CONFIG_V2_1":"C:\\Program Files\\GenICam_v2_1\\log\\config\\DebugLogging.properties","GENICAM_ROOT_V2_1":"C:\\Program Files\\GenICam_v2_1","GIT_LFS_PATH":"C:\\Program Files\\Git LFS","HOMEDRIVE":"C:","HOMEPATH":"\\Users\\User","INTEL_LICENSE_FILE":"C:\\Program Files (x86)\\Common Files\\Intel\\Licenses","IVP_3D_CAMERA":"C:\\Program Files (x86)\\SICK\\3D Cameras\\","LOCALAPPDATA":"C:\\Users\\User\\AppData\\Local","LOGONSERVER":"\\\\KOSTIK-2019","MKL_CBWR":"AVX","MY_SDK_PATH":"c:\\vs\\SDKs\\","NUMBER_OF_PROCESSORS":"16","NVCUDASAMPLES11_3_ROOT":"C:\\ProgramData\\NVIDIA Corporation\\CUDA Samples\\v11.3","NVTOOLSEXT_PATH":"C:\\Program Files\\NVIDIA Corporation\\NvToolsExt\\","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","OS":"Windows_NT","OneDrive":"C:\\Users\\User\\OneDrive","OneDriveConsumer":"C:\\Users\\User\\OneDrive","PATHEXT":".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC","PROCESSOR_ARCHITECTURE":"AMD64","PROCESSOR_IDENTIFIER":"Intel64 Family 6 Model 158 Stepping 13, GenuineIntel","PROCESSOR_LEVEL":"6","PROCESSOR_REVISION":"9e0d","PSModulePath":"C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules","PUBLIC":"C:\\Users\\Public","PUREGEV_ROOT":"C:\\Program Files (x86)\\Pleora Technologies Inc\\eBUS SDK\\","Path":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\Ninja;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.20348.0\\x86;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX86\\x64;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.39.33519\\bin\\HostX86\\x86;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\IDE\\VC\\VCPackages;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\MSBuild\\Current\\bin\\Roslyn;C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Common\\VSPerfCollectionTools\\vs2019\\\\x64;C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Common\\VSPerfCollectionTools\\vs2019\\;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.8 Tools\\;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\IDE\\CommonExtensions\\Microsoft\\FSharp\\Tools;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Team Tools\\DiagnosticsHub\\Collector;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.20348.0\\\\x86;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\\\x86;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\\\MSBuild\\Current\\Bin\\amd64;C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\IDE\\;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\Tools\\;c:\\vs\\SDKs\\TensorRT-8.6.1.6\\lib\\;c:\\vs\\SDKs\\cudnn-11.x-v8.9.0\\bin\\;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.8\\libnvvp;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.8\\bin;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.3\\bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.3\\libnvvp;C:\\Program Files (x86)\\SICK\\3D Cameras\\icon\\lib;C:\\Program Files (x86)\\Common Files\\Intel\\Shared Files\\fortran\\bin\\ia32;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\iCLS\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\iCLS\\;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\;C:\\Program Files\\TortoiseHg\\;C:\\Program Files\\dotnet\\;C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn\\;C:\\Program Files\\nodejs\\;C:\\Program Files (x86)\\Common Files\\Pleora\\eBUS SDK;C:\\Program Files\\Common Files\\Pleora\\eBUS SDK;C:\\Program Files\\Automation Technology GmbH\\CXExplorer (64Bit)\\SAL3D\\bin;C:\\Program Files\\GenICam_v2_1\\bin\\Win64_x64;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Program Files\\STEMMER IMAGING\\Common Vision Blox\\;C:\\Program Files\\STEMMER IMAGING\\Common Vision Blox\\Qt\\;C:\\Program Files\\Git LFS;C:\\Program Files\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\PuTTY\\;C:\\miktex\\;C:\\Program Files (x86)\\Tvema\\CudaRT 11.3\\;C:\\Program Files\\WireGuard\\;C:\\Program Files\\Git\\cmd;C:\\Program Files (x86)\\GitExtensions\\;C:\\Program Files\\NVIDIA Corporation\\Nsight Compute 2022.3.0\\;C:\\Users\\User\\scoop\\shims;C:\\Users\\User\\.dotnet\\tools;C:\\Program Files\\ConEmu\\ConEmu\\Scripts;C:\\Program Files\\ConEmu;C:\\Program Files\\ConEmu\\ConEmu;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.3\\bin;C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.3\\libnvvp;C:\\Program Files (x86)\\SICK\\3D Cameras\\icon\\lib;C:\\Program Files (x86)\\Common Files\\Intel\\Shared Files\\fortran\\bin\\ia32;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\iCLS\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\iCLS\\;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Microsoft SQL Server\\130\\;C:\\Program Files\\CMake\\bin;C:\\Users\\User\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Users\\User\\.dotnet\\tools;;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\Ninja;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\IDE\\VC\\Linux\\bin\\ConnectionManagerExe","ProgramData":"C:\\ProgramData","ProgramFiles":"C:\\Program Files","ProgramFiles(x86)":"C:\\Program Files (x86)","ProgramW6432":"C:\\Program Files","SAL3DDIR":"C:\\Program Files\\Automation Technology GmbH\\CXExplorer (64Bit)\\SAL3D","SAPERADIR":"C:\\Program Files\\Teledyne DALSA\\Sapera","SAPERA_GENICAM_ROOT":"C:\\Program Files\\Teledyne DALSA\\Sapera\\GenICam_2_1","SESSIONNAME":"Console","SystemDrive":"C:","SystemRoot":"C:\\WINDOWS","TEMP":"C:\\Users\\User\\AppData\\Local\\Temp","TMP":"C:\\Users\\User\\AppData\\Local\\Temp","USERDOMAIN":"KOSTIK-2019","USERDOMAIN_ROAMINGPROFILE":"KOSTIK-2019","USERNAME":"User","USERPROFILE":"C:\\Users\\User","VS140COMNTOOLS":"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\","VS2017INSTALLDIR":"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise","VS2019INSTALLDIR":"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Professional","VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CODE_CACHE_PATH":"C:\\Users\\User\\AppData\\Roaming\\Code\\CachedData\\dc96b837cf6bb4af9cd736aa3af08cf8279f7685","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"C:\\WINDOWS\\system32","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"\\\\.\\pipe\\7a324ef7-1.89.1-main-sock","VSCODE_L10N_BUNDLE_LOCATION":"","VSCODE_NLS_CONFIG":"{\"locale\":\"en-us\",\"osLocale\":\"en-us\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_PID":"20424","VXIPNPPATH":"C:\\Program Files (x86)\\IVI Foundation\\VISA\\","VXIPNPPATH64":"C:\\Program Files\\IVI Foundation\\VISA\\","WIX":"C:\\Program Files (x86)\\WiX Toolset v3.11\\","windir":"C:\\WINDOWS","DevEnvDir":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\IDE\\","Framework40Version":"v4.0","FrameworkDir":"C:\\Windows\\Microsoft.NET\\Framework\\","FrameworkDIR32":"C:\\Windows\\Microsoft.NET\\Framework\\","FrameworkDIR64":"C:\\Windows\\Microsoft.NET\\Framework64","FrameworkVersion":"v4.0.30319","FrameworkVersion32":"v4.0.30319","FrameworkVersion64":"v4.0.30319","INCLUDE":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.39.33519\\include;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.39.33519\\ATLMFC\\include;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Auxiliary\\VS\\include;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.20348.0\\ucrt;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.20348.0\\\\um;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.20348.0\\\\shared;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.20348.0\\\\winrt;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.20348.0\\\\cppwinrt;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\include\\um","LIB":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.39.33519\\ATLMFC\\lib\\x64;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.39.33519\\lib\\x64;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\lib\\um\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.20348.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\\\lib\\10.0.20348.0\\\\um\\x64","LIBPATH":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.39.33519\\ATLMFC\\lib\\x64;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.39.33519\\lib\\x64;C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.39.33519\\lib\\x86\\store\\references;C:\\Program Files (x86)\\Windows Kits\\10\\UnionMetadata\\10.0.20348.0;C:\\Program Files (x86)\\Windows Kits\\10\\References\\10.0.20348.0;C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319","NETFXSDKDir":"C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\","UCRTVersion":"10.0.20348.0","UniversalCRTSdkDir":"C:\\Program Files (x86)\\Windows Kits\\10\\","VCIDEInstallDir":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\IDE\\VC\\","VCINSTALLDIR":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\","VCToolsRedistDir":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Redist\\MSVC\\14.38.33135\\","VisualStudioVersion":"17.0","VSINSTALLDIR":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\","WindowsLibPath":"C:\\Program Files (x86)\\Windows Kits\\10\\UnionMetadata\\10.0.20348.0;C:\\Program Files (x86)\\Windows Kits\\10\\References\\10.0.20348.0","WindowsSdkBinPath":"C:\\Program Files (x86)\\Windows Kits\\10\\bin\\","WindowsSdkDir":"C:\\Program Files (x86)\\Windows Kits\\10\\","WindowsSDKLibVersion":"10.0.20348.0\\","WindowsSDKVersion":"10.0.20348.0\\","WindowsSDK_ExecutablePath_x64":"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.8 Tools\\x64\\","WindowsSDK_ExecutablePath_x86":"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.8 Tools\\","VS170COMNTOOLS":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\Common7\\Tools","CC":"cl.exe","CXX":"cl.exe"}
[cmake] -- Selecting Windows SDK version 10.0.20348.0 to target Windows 10.0.19045.
[cmake] -- The C compiler identification is MSVC 19.39.33520.0
[cmake] -- The CXX compiler identification is MSVC 19.39.33520.0
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - done
[cmake] -- Configuring done (3.5s)
[cmake] -- Generating done (0.0s)
[cmake] CMake Warning:
[cmake]   Manually-specified variables were not used by the project:
[cmake] 
[cmake]     CMAKE_BUILD_TYPE
[cmake] 
[cmake] 
[cmake] -- Build files have been written to: C:/vs/VSCodeCmakeTest/build/win-x64-debug
[cmakefileapi-parser] Read reply folder: C:\vs\VSCodeCmakeTest\build\win-x64-debug\.cmake\api\v1\reply
[cmakefileapi-parser] Found index files: ["cache-v2-366d2f9553ff6fcb05ec.json","cmakeFiles-v1-e901eafde8f8adb865ff.json","codemodel-v2-19d761be260d32697e51.json","directory-.-Debug-d0094a50bb2071803777.json","index-2024-05-20T10-23-39-0256.json","target-ALL_BUILD-Debug-26f43c8a8230e42424ad.json","target-main-Debug-23f0458a1fb6cdf1ff26.json","target-ZERO_CHECK-Debug-d264778c7918b426b938.json","toolchains-v1-c373e0518942c8630c0a.json"]
[expand] expanding cmake
[expand] expanding cmake
[cache] Reading CMake cache file C:/vs/VSCodeCmakeTest/build/win-x64-debug/CMakeCache.txt
[cache] Parsing CMake cache string
[expand] expanding cmake
[extension] [6527] cmake.cleanConfigure finished (returned {"result":0,"resultType":0})
[expand] expanding cmake
[cache] Reading CMake cache file C:/vs/VSCodeCmakeTest/build/win-x64-debug/CMakeCache.txt
[cache] Parsing CMake cache string

Additional Information

No response

@v-frankwang
Copy link
Collaborator

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

@v-frankwang v-frankwang added more info needed More info is needed from the community for us to properly triage and investigate. and removed triage labels May 23, 2024
@kokostek
Copy link
Author

kokostek commented May 23, 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.

@v-frankwang
Copy link
Collaborator

v-frankwang commented May 24, 2024

@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

@v-frankwang v-frankwang added bug a bug in the product and removed more info needed More info is needed from the community for us to properly triage and investigate. labels May 24, 2024
@gcampbell-msft gcampbell-msft moved this from Triage Needed to Ready to be Assigned in CMake Tools Jun 24, 2024
@gcampbell-msft gcampbell-msft added this to the 1.19 milestone Jun 24, 2024
@jophippe jophippe moved this from Ready to be Assigned to To Do in CMake Tools Jun 26, 2024
@jophippe jophippe moved this from To Do to In Progress in CMake Tools Jun 26, 2024
@jophippe
Copy link
Contributor

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

@kokostek
Copy link
Author

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

@github-project-automation github-project-automation bot moved this from In Progress to Completed in CMake Tools Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug a bug in the product Feature: configure
Projects
Status: Completed
Development

No branches or pull requests

4 participants