简体   繁体   English

VSCode C++ IntelliSense 看不到项目目录中的文件

[英]VSCode C++ IntelliSense doesn't see files in project directories

I am developing in Visual Studio Code a C++ application, for which a linter is fundamental.我正在 Visual Studio Code 中开发一个 C++ 应用程序,linter 是其基础。

**Compiler **(Makefile) OK ✔ **Intellisense **ERROR X . **编译器 **(Makefile) OK ✔ **Intellisense **错误X。

My PC is Windows, but I use the Remote Explorer with SSH on a Linux server/machine**.我的 PC 是 Windows,但我在 Linux 服务器/机器上使用 Remote Explorer 和 SSH**。 Target platform(OS) for the application is Linux.该应用程序的目标平台 (OS) 是 Linux。

I installed the C/C++ package with IntelliSense, followed setup guides and troubleshooting, but for some reasons I still get a:我安装了带有 IntelliSense 的 C/C++ package,按照安装指南和故障排除,但由于某些原因我仍然得到:

cannot open source file "header.h"

Where header.h is a file from another directory in my project.其中header.h是我项目中另一个目录中的文件。 when importing header files from my own project.从我自己的项目导入 header 文件时。 My project directory tree looks like this:我的项目目录树如下所示:

home/project/    //--> this is my ${workspaceFolder}
----include/
--------header1.h
--------header2.h
----src/specific_implement/
--------implementation.cpp

Reasuming:恢复:

  • #include "header1.h" // in header2.h file OK
  • #include <stdio.h> // any file OK
  • #include "header1.h" // in implementation.cpp file ERROR

I tried installing an older version of the C/C++ package and it worked for 1 day, then reopening the project broke everything again.我尝试安装旧版本的 C/C++ package,它工作了 1 天,然后重新打开项目再次破坏了一切。

I edited the c_cpp_properties.json file adding the specific path that contains my include, but I still get the error.我编辑了c_cpp_properties.json文件,添加了包含我的包含的特定路径,但我仍然收到错误。

My json file looks like this:我的 json 文件如下所示:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/home/project/include/"
            ],
     "browse": {
                "path": [
                    "${workspaceFolder}/**",
                    "/home/project/include/"
                ],

Browse path recognised the file the day IntelliSense worked...浏览路径在 IntelliSense 工作的那一天识别了文件...

Maybe your C_Cpp: Intelli Sense Engine is disabled也许您的 C_Cpp: Intelli Sense Engine 已禁用

Go to File -> Preferences -> Settings or Ctrl+, Go 到 File -> Preferences -> Settings 或 Ctrl+,

Search Intelli Sense Engine and set to Default.搜索 Intelli Sense Engine 并设置为默认值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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