Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Action for missing headers #11291

Closed
karpathyan opened this issue Aug 4, 2023 · 3 comments
Closed

Code Action for missing headers #11291

karpathyan opened this issue Aug 4, 2023 · 3 comments

Comments

@karpathyan
Copy link

Environment

  • OS and Version: Ubuntu 23.04
  • VS Code Version: 1.81.0
  • C/C++ Extension Version: 1.16.3
  • If using SSH remote, specify OS of remote machine: using locally
    vscode-std_vector_error
Visual studio code
Version: 1.81.0
Commit: 6445d93c81ebe42c4cbd7a60712e0b17d9463e97
Date: 2023-08-02T12:36:11.334Z
Electron: 22.3.18
ElectronBuildId: 22689846
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Linux x64 6.2.0-26-generic snap

Bug Summary and Steps to Reproduce

Bug Summary:
When I try to define a variable as std:: vector, the IntelliSense engine is raising the following error:

namespace "std" has no member "vector"C/C++(135)

Steps to reproduce: Probably non reproducible
Expected behavior: std:: should list vector and give and display the doc-strings.

Configuration and Logs

- c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc"
        }
    ],
    "version": 4
}
  • Logs from running C/C++: Log Diagnostics
-------- Diagnostics - 8/4/2023, 1:30:56 PM
Version: 1.16.3
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/home/rcheenikundil/Desktop/FinDiff/Mmagsolve/**"
    ],
    "defines": [],
    "compilerPath": "/usr/bin/gcc",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerPathInCppPropertiesJson": "/usr/bin/gcc",
    "cStandard": "c11",
    "cppStandard": "c++11",
    "intelliSenseMode": "linux-gcc-x64",
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
cpptools version (native): 1.16.3.0
Translation Unit Mappings:
[ /home/rcheenikundil/Desktop/FinDiff/Mmagsolve/read_file.cpp ]:
    /home/rcheenikundil/Desktop/FinDiff/Mmagsolve/read_file.cpp
Translation Unit Configurations:
[ /home/rcheenikundil/Desktop/FinDiff/Mmagsolve/read_file.cpp ]:
    Process ID: 13600
    Memory Usage: 631 MB
    Compiler Path: /usr/bin/gcc
    Includes:
        /usr/include/c++/12
        /usr/include/x86_64-linux-gnu/c++/12
        /usr/include/c++/12/backward
        /usr/lib/gcc/x86_64-linux-gnu/12/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Standard Version: c++11
    IntelliSense Mode: linux-gcc-x64
    Other Flags:
        --g++
        --gnu_version=120200
Total Memory Usage: 631 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 37616

  • Launch.json
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830>
    "version": "0.2.0",
    "configurations": []
}
  • settings.json
        "optional": "cpp",
        "random": "cpp",
        "ratio": "cpp",
        "string_view": "cpp",
        "system_error": "cpp",
        "tuple": "cpp",
        "type_traits": "cpp",
        "utility": "cpp",
        "hash_map": "cpp",
        "hash_set": "cpp",
        "slist": "cpp",
        "fstream": "cpp",
        "future": "cpp",
        "initializer_list": "cpp",
        "iomanip": "cpp",
        "iosfwd": "cpp",
        "iostream": "cpp",
        "istream": "cpp",
        "limits": "cpp",
        "mutex": "cpp",
        "new": "cpp",
        "numbers": "cpp",
        "ostream": "cpp",
        "semaphore": "cpp",
        "shared_mutex": "cpp",
        "sstream": "cpp",
        "stdexcept": "cpp",
        "stop_token": "cpp",
        "streambuf": "cpp",
        "thread": "cpp",
        "cfenv": "cpp",
        "typeindex": "cpp",
        "typeinfo": "cpp",
        "valarray": "cpp",
        "variant": "cpp",
        "__nullptr": "cpp"
    }
}
  • tasks.json
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: cpp build active file",
            "command": "/usr/bin/cpp",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}
  • output of $ g++ --version
g++ (Ubuntu 12.2.0-17ubuntu1) 12.2.0
  • gcc --version
gcc (Ubuntu 12.2.0-17ubuntu1) 12.2.0
- which gcc

/usr/bin/gcc



### Other Extensions

_No response_

### Additional context

This is probably caused by a mistake in defining some of the many variables in the `cpptools` settings. Can anyone please help me identify what is the mistake I made? Thanks. Please let me know if any further files are required. 
@johnwsmithv
Copy link

Have you tried:

#include <vector>

That should fix your problem.

@bobbrow
Copy link
Member

bobbrow commented Aug 4, 2023

@johnwsmithv's suggestion should resolve the issue. Though I'd like for us to do what Visual Studio does and offer a "quick fix" for this since we would already know where std::vector is defined.

I'll mark this as a feature request.

@bobbrow bobbrow changed the title IntelliSense complaining that: namespace "std" has no member "vector"C/C++(135) Code Action for missing headers Aug 4, 2023
@bobbrow bobbrow added this to the On Deck milestone Aug 4, 2023
@bobbrow
Copy link
Member

bobbrow commented Aug 7, 2023

I found a duplicate issue tracking this feature request. Closing this one. #10791

@bobbrow bobbrow closed this as not planned Won't fix, can't repro, duplicate, stale Aug 7, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants