我按照 Microsoft 的这篇 C/C++ for Visual Studio Code 文章使用 Visual Studio Code 编写 C++。与显示智能感知提供成员函数文档的文章不同,它没有向我显示任何内容。同样的事情也发生在 Visual Studio 2019 中。
到目前为止我尝试解决的问题:
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe",
"cStandard": "c17",
"intelliSenseMode": "windows-msvc-x64",
"cppStandard": "c++14"
}
],
"version": 4
}
设置.json{
"files.associations": {
"xstring": "cpp"
}
}
任务.json{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/nologo",
"/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$msCompile"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
libstdc++ 的设置,其中包含包含该文档的 C++ 注释。由于您使用的是 Visual Studio,因此您正在使用 Microsoft 的 C++ 标准库实现。浏览他们的标题,似乎 Microsoft STL 不包含此类文档注释。
您可以在他们的讨论板上提出问题,询问是否有好的解决方法/替代方案,或者(礼貌地)询问他们为什么不维护此类文档注释,或者他们将来是否有计划。我没用过这个,但你可能有兴趣尝试一下这个 VS Code 扩展:
Guyutongxue.cpp-reference (我与这个扩展没有任何关系),哪个
是一个从 vscode 中浏览 cppreference.com 的工具,而不是通过浏览器来执行此操作。您可以使用此扩展来搜索 C++ 标准的库和方法文档。