Reputation: 67
When I use VS code, it takes hints from MSVC's standard library headers (they also can be seen by pressing "go to definition"), which barely has any documentation comments or hints. However, GCC's standard library header source code has much better documentation comments. I didn't find any settings or tasks that change this. Is there a way to change it?
Upvotes: 2
Views: 938
Reputation: 50315
Write a c_cpp_properties.json
file.
Quoting from the docs for the compilerPath
property:
The extension will query the compiler to determine the system include paths and default defines to use for IntelliSense.
Putting
"compilerPath": ""
(empty string) will skip querying a compiler. This is useful if a specified compiler doesn't support the arguments that are used for the query, as the extension will default back to any compiler it can find (like Visual C). Leaving out thecompilerPath
property does not skip the query.
Quoting the docs for the includePath
property:
If on Windows with Visual Studio installed, or if a compiler is specified in the
compilerPath
setting, it is not necessary to list the system include paths in this list.
Note also that you can specify system include paths as a setting, C_Cpp.default.systemIncludePath
, with related docs here and here.
VS Code's various setup guides for C++ on different platforms / platform toolchain setups, they each have a section on how to configure the c_cpp_properties.json
file for that toolchain+plaform combination. You'll find it really helpful, because each of those sections shows a code snippet of the basic setup.
Here are links to all the current toolchain+platform sub-pages at the relevant section (I'll inline the snippets for the Windows GCC ones just for you, but please do also check out those pages for up-to-date versions):
GCC on Windows via MinGW > C/C++ configurations
{
"configurations": [
{
"name": "GCC",
"includePath": ["${workspaceFolder}/**"],
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/msys64/mingw64/bin/g++.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}
GCC on Windows Subsystem For Linux > C/C++ configurations
{
"configurations": [
{
"name": "Linux",
"includePath": ["${workspaceFolder}/**"],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
Use the vscode.cmake-tools
extension, and either instruct the extension to scan for kits that can be found on your system, or set up (and tell VS Code to use) a CMake Presets file with where to find the compilers. Compilers usually know by default where their standard library headers are (if they come with them, which packages for compilers usually do).
Upvotes: 1