【问题标题】:Intellisense does not show function descriptions in Visual Studio Code for C++ using the clang++ compiler on macOSIntellisense 不在 macOS 上使用 clang++ 编译器的 Visual Studio Code for C++ 中显示函数描述
【发布时间】:2022-07-08 16:45:16
【问题描述】:

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

  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 有关——虽然代码完成/建议工作正常,但我只是看不到任何功能描述。 这是一个简单的例子: No description for the append() function

如果我转到字符串附加函数的定义,它会将我带到 /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 显示完整的文档(即用“简单英语”告诉我函数的作用)?

谢谢!

【问题讨论】:

    标签: c++ visual-studio-code vscode-settings intellisense clang++


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-16
      • 1970-01-01
      • 2020-09-04
      • 1970-01-01
      • 2018-01-19
      • 1970-01-01
      • 2019-03-13
      相关资源
      最近更新 更多