简体   繁体   中英

Intellisense does not show function descriptions in Visual Studio Code for C++ using the clang++ compiler on macOS

So I'm just starting to learn C++ and I decided to use Visual Studio Code as my development environment and use the clang++ compiler on macOS. I followed the official Using Clang in Visual Studio Code guide and ended up with the following configuration files:

  1. tasks.json (compiler build settings)
{
   "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 (debugger settings)
{
   "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 (compiler path and IntelliSense settings)
{
    "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
}

Now my problem has to do with Intellisense -- while the code completion/suggestion works fine, I just don't see any of the function descriptions. Here is a simple example: No description for the append() function

If I go to the definition of the string append function, it takes me to /Library/Developer/CommandLineTools/usr/include/c++/v1/string . And yes, this file happens indeed to not have any descriptive documentation in it. Here's what it says at the top:

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

Therefore, does anyone know what I should do in order for Intellisense to show the complete documentation (ie tell me what the functions do in 'plain English')?

Thanks!

I had the same issue. I found this post . I ended up installing gcc in Homebrew, but didn't set "compilerPath": "/opt/homebrew/Cellar/gcc/11.2.0/bin/g++-11" and got the function description showing up properly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM