vscode-cpptools
vscode-cpptools copied to clipboard
IntelliSense failure: spam "Attempting to get defaults from C++ compiler" while using compile_commands.json
Environment
- OS and Version: Windows10
- VS Code Version: 1.71.0
- C/C++ Extension Version: 1.13.0
- Other extensions you installed (and if the issue persists after disabling them): disabling extensions doesn't change behavior
- Remote: N/A
- Description: No navigation or autocomplete in UE5 based project with over 30k source files.
Bug Summary and Steps to Reproduce
Problem: no navigation / autocomplete in any opened project source file for 4+ hours (didn't run it any longer to test how much time it take to finish indexing) Setup: UE5 based project with over 30k source files, one of the generated compile_commands.json contains over 448k lines. Content looks like this:
{
"file": "<absolute/path/to.cpp>",
"arguments": [
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\cl.exe",
"@D:\\Workspace\\Main\\.vscode\\compileCommands_Default\\<module_name>.1149.rsp"
],
"directory": "D:\\Workspace\\Main\\Engine\\Source"
},
{
"file": "<absolute/path/to.cpp>",
"arguments": [
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\cl.exe",
"@D:\\Workspace\\Main\\.vscode\\compileCommands_Default\\<module_name>.1149.rsp"
],
"directory": "D:\\Workspace\\Main\\Engine\\Source"
},
where argument[0] is always the same path to the compiler.
With "C_Cpp.loggingLevel": "Debug" C/C++ output overflow with a spam:
Attempting to get defaults from C++ compiler in compile_commands.json file: 'C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe'
Attempting to get defaults from C++ compiler in compile_commands.json file: 'C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe'
Attempting to get defaults from C++ compiler in compile_commands.json file: 'C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe'
Attempting to get defaults from C++ compiler in compile_commands.json file: 'C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe'
I ran an experiment of reducing number of compile command entries and proved that number of "Attempting to get defaults" log entries correlate with number of items in compile_commands.json.
Steps to reproduce:
- create empty [1-5].cpp files
- add .vscode/c_cpp_properties.json with content:
{
"configurations": [
{
"name": "Win32",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64",
"compileCommands": "${workspaceRoot}\\.vscode\\compile_commands.json"
}
],
"version": 4
}
- create .vscode\compile_commands.json" with content:
[
{
"directory": "D:/Workspace/testcpp/build",
"arguments": [
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\cl.exe",
"-std:c++20"
],
"file": "D:\\Workspace\\testcpp\\src\\main.cpp"
},
{
"directory": "D:/Workspace/testcpp/build",
"arguments": [
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\cl.exe",
"-std:c++20"
],
"file": "D:\\Workspace\\testcpp\\src\\1.cpp"
},
{
"directory": "D:/Workspace/testcpp/build",
"arguments": [
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\cl.exe",
"-std:c++20"
],
"file": "D:\\Workspace\\testcpp\\src\\2.cpp"
},
{
"directory": "D:/Workspace/testcpp/build",
"arguments": [
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\cl.exe",
"-std:c++20"
],
"file": "D:\\Workspace\\testcpp\\src\\3.cpp"
},
{
"directory": "D:/Workspace/testcpp/build",
"arguments": [
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\cl.exe",
"-std:c++20"
],
"file": "D:\\Workspace\\testcpp\\src\\4.cpp"
},
{
"directory": "D:/Workspace/testcpp/build",
"arguments": [
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Professional\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\cl.exe",
"-std:c++20"
],
"file": "D:\\Workspace\\testcpp\\src\\5.cpp"
}
]
- add "C_Cpp.loggingLevel": "Debug" to settings.json
- Reload window
- Open C/C++ output panel Observe:
Code browsing service initialized
Attempting to get defaults from C++ compiler in compile_commands.json file: 'C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe'
Attempting to get defaults from C++ compiler in compile_commands.json file: 'C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe'
Attempting to get defaults from C++ compiler in compile_commands.json file: 'C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe'
Attempting to get defaults from C++ compiler in compile_commands.json file: 'C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe'
Attempting to get defaults from C++ compiler in compile_commands.json file: 'C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe'
My understanding of the problem is that compiler's default include paths\defines\options can't be changed, so the results could be shared among all compile_commands items using same compiler. And second: intellisense database building could be started from opened file first, and then incrementally adding symbols in a background. Reachable symbols from current opened file should be enough for navigation and most of autocompletion at the start.
Expected behavior
Navigation and autocomplete works
Code sample and Logs
In the description.
Screenshots
No response
Additional context
No response
Hi @rxcompile . I don't believe the log output you are referring to is related to your IntelliSense issue. That line is logged simply as each entry in the compile_commands.json file is evaluated. There is actually no probing that is done of cl.exe, as the extension implicitly knows where to find headers for cl.exe (relative to the executable) and knows of all cl.exe's system defines. We could reduce the logging here, but I don't believe this logging is causing your issue.
Note that there have been known issues in recent releases of UnrealEngine, in which not all files are included in their compile_commands.json files, leading to IntelliSense missing for those files.
https://github.com/microsoft/vscode-cpptools/issues/8812#issuecomment-1188428270 https://github.com/microsoft/vscode-cpptools/issues/5849#issuecomment-1188469540
If you believe you are seeing an issue with IntelliSense that is not due to an issue with UnrealEngine's project configuration, could you provide a self-contained repro that we might investigate further?
Yeah, the logging is just incorrect and happens too early before it checks the cache (when querying gcc/clang).
This issue has been closed because it needs more information and has not had recent activity.
The fix is available with 1.15.0 (pre-release): https://github.com/microsoft/vscode-cpptools/releases/tag/v1.15.0