Intellisense在macOS上使用clang++编译器的Visual Studio Code for C++中不



所以我刚开始学习C++,我决定使用Visual Studio Code作为我的开发环境,并在macOS上使用clang++编译器。我遵循了官方的《在Visual Studio中使用Clang代码》指南,最终得到了以下配置文件:

  1. tasks.json(编译器构建设置(
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "[mthree] clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
  1. launch.json(调试器设置(
{
"version": "0.2.0",
"configurations": [
{
"name": "[mthree] clang++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "[mthree] clang++ build active file"
}
]
}
  1. c_cpp_properties.json(编译器路径和IntelliSense设置(
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang++",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-x64"
}
],
"version": 4
}

现在我的问题与Intellisense有关——虽然代码完成/建议工作得很好,但我只是看不到任何函数描述。下面是一个简单的例子:没有对append((函数的描述

如果我转到字符串附加函数的定义,它将带我进入/Library/Developer/CommandLineTools/usr/include/c++/v1/string。是的,这个文件中确实没有任何描述性的文档

// -*- C++ -*-
//===--------------------------- string -----------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

因此,有人知道我应该做什么才能让Intellisense显示完整的文档吗(即用"简明英语"告诉我函数的作用(?

谢谢!

我遇到了同样的问题。我找到了这个帖子。我最终在Homebrew中安装了gcc,但没有设置"compilerPath": "/opt/homebrew/Cellar/gcc/11.2.0/bin/g++-11",并且正确显示了功能描述。

最新更新