-
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
MSVC IntelliSense mode configuration should use MSVC Environment variables (CL
, _CL_
, INCLUDE
, LIBPATH
)
#9745
Comments
Is this a C++/CLI project? Can you share a small sample? We can take a look and see if CMake is providing us the correct info in the cmake-file-api or not. |
Here's a basic reproducer:
(This reproducer uses msbuild because it's more minimal that way - the issue seems to occur on both msbuild and Ninja) |
Thank you! It appears that cpptools needs to add the value of %NETFXSDKDir% to the list of system include paths. I see it there in the %INCLUDE% variable in the Developer Command Prompt. |
Based on the info here: https://docs.microsoft.com/en-us/cpp/build/reference/cl-environment-variables?view=msvc-170 It looks like cpptools needs to consider the values of the following environment variables when configuring IntelliSense for cl.exe.
|
CL
, _CL_
, INCLUDE
, LIBPATH
)
Yes, however not everyone launches VS Code from a Developer Command Prompt. In the event that %INCLUDE% is not available, we'll need to add logic to search for the probable location of %NETFXSDKDir% (which also won't be available) and add that to the system include path. |
Fixed with 1.13.4 (pre-release): https://github.com/microsoft/vscode-cpptools/releases/tag/v1.13.4 |
Brief Issue Summary
I've created a small VSCode project that builds a native DLL on Windows, using CMake and Ninja (basically took the template created by Visual Studio). The project includes files from the .Net SDK.
Somehow, the CMake Tools extension is able to configure and build this project just fine (without me having to tell it where the Visual Studio tools and the .Net SDK is), but when configuring the c_cpp extension (for intellisense and such), the configuration seems incomplete and does not include the .Net SDK header directories, which forces me to avoid this auto-configuration and manually specify the directory.
I'm tried running vscode from a "vcvars" command prompt as suggested by documentation, it seems to make no difference.
When starting a vcvars64.bat session and configuring/building the project from command line, it looks like the CL.exe command line doesn't include the .Net SDK path either, so I guess CL is finding the header files from the INCLUDE environment variable that is set by vcvars64.bat - This might suggest that this is really a CMake issue (shouldn't CMake create a makefile that has all information needed to build, without relying on env vars?), but I figured I'd start with this project and see where it goes. In any case, I really don't understand why some Visual C++ /SDK directories are passed to c_cpp extension and some don't.
Thanks,
Uri.
CMake Tools Diagnostics
Debug Log
Additional Information
Debug log of the c_cpp extension upon running CMake: Configure:
cpptools/fileCreated: C:\dev\vfagent.net\out\build\x64-debug.cmake\api\v1\reply\index-2022-08-16T11-14-59-0730.json
Checking for syntax errors: C:\dev\vfagent.net\agent\CorProfiler.h
Queueing IntelliSense update for files in translation unit of: C:\dev\vfagent.net\agent\CorProfiler.cpp
cpptools/fileDeleted: C:\dev\vfagent.net\out\build\x64-debug.cmake\api\v1\tmp.json
cpptools/fileDeleted: C:\dev\vfagent.net\out\build\x64-debug.cmake\api\v1\reply\index-2022-08-16T08-16-12-0836.json
Custom browse configuration received: {
"browsePath": [
"c:/dev/vfagent.net/agent/asmhelpers/amd64/windows",
"c:/dev/vfagent.net/agent"
],
"compilerPath": "c:/program files/microsoft visual studio/2022/professional/vc/tools/msvc/14.32.31326/bin/hostx64/x64/cl.exe",
"compilerArgs": [],
"compilerFragments": [
"/DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1",
"-std:c++20"
]
}
cpptools/clearCustomConfigurations
Checking for syntax errors: C:\dev\vfagent.net\agent\CorProfiler.h
Shutting down IntelliSense server: C:\dev\vfagent.net\agent\CorProfiler.cpp
cpptools/queryTranslationUnitSource: C:\dev\vfagent.net\agent\CComPtr.h (id: 49)
Custom configurations received:
uri: file:///c%3A/dev/vfagent.net/agent/CorProfiler.cpp
config: {
"includePath": [],
"defines": [
"_CRT_SECURE_NO_WARNINGS",
"vfagent_net_EXPORTS"
],
"compilerPath": "c:/program files/microsoft visual studio/2022/professional/vc/tools/msvc/14.32.31326/bin/hostx64/x64/cl.exe",
"compilerArgs": [],
"compilerFragments": [
"/DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1",
"-std:c++20"
]
}
cpptools/didChangeCustomBrowseConfiguration
Attempting to get defaults from C++ compiler in "compilerPath" property: 'c:/program files/microsoft visual studio/2022/professional/vc/tools/msvc/14.32.31326/bin/hostx64/x64/cl.exe'
cpptools/didChangeCustomConfiguration
Attempting to get defaults from C++ compiler in "compilerPath" property: 'c:/program files/microsoft visual studio/2022/professional/vc/tools/msvc/14.32.31326/bin/hostx64/x64/cl.exe'
cpptools/queryTranslationUnitSource: C:\dev\vfagent.net\agent\CorProfiler.h (id: 50)
cpptools/resumeParsing
sending compilation args for C:\dev\vfagent.net\agent\CorProfiler.cpp
include: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\PROFESSIONAL\VC\TOOLS\MSVC\14.32.31326\INCLUDE
include: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\PROFESSIONAL\VC\TOOLS\MSVC\14.32.31326\ATLMFC\INCLUDE
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UM
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UCRT
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\SHARED
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\WINRT
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\CPPWINRT
define: _DEBUG
define: _MT
define: _DLL
other: --rtti
stdver: ms_c++20
intelliSenseMode: windows-msvc-x64
Shutting down IntelliSense server: C:\dev\vfagent.net\agent\CorProfiler.cpp
sending compilation args for C:\dev\vfagent.net\agent\CorProfiler.cpp
include: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\PROFESSIONAL\VC\TOOLS\MSVC\14.32.31326\INCLUDE
include: C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\PROFESSIONAL\VC\TOOLS\MSVC\14.32.31326\ATLMFC\INCLUDE
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UM
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\UCRT
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\SHARED
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\WINRT
include: C:\PROGRAM FILES (X86)\WINDOWS KITS\10\INCLUDE\10.0.19041.0\CPPWINRT
define: _DEBUG
define: _MT
define: _DLL
define: _CRT_SECURE_NO_WARNINGS
define: vfagent_net_EXPORTS
define: WIN32
define: _WINDOWS
other: --rtti
stdver: ms_c++20
intelliSenseMode: windows-msvc-x64
Checking for syntax errors: C:\dev\vfagent.net\agent\CorProfiler.h
Queueing IntelliSense update for files in translation unit of: C:\dev\vfagent.net\agent\CorProfiler.cpp
cpptools/finishUpdateSquiggles
Error squiggle count: 191
Error squiggles will be disabled in: file:///C%3A/dev/vfagent.net/agent/CorProfiler.h
Update IntelliSense time (sec): 1.32
cpptools/getSemanticTokens: C:\dev\vfagent.net\agent\CorProfiler.h (id: 51)
INCLUDE environment variable from "vcvars64.bat":
INCLUDE=C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.32.31326\ATLMFC\include;C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.32.31326\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt
LIB=C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.32.31326\ATLMFC\lib\x64;C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.32.31326\lib\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.19041.0\um\x64
The text was updated successfully, but these errors were encountered: