最近在VSCode上运行C++文件,但是引入头文件时会提示错误

无法导入头文件,找不到路径

 在网上找了一下,是c_cpp_properties.json 文件的问题

需要把自己的头文件导入进来

我使用的是MinGW

 

c_cpp_properties.json文件如下:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "g:/mingw/lib/gcc/mingw32/6.3.0/include/c++",
                "g:/mingw/lib/gcc/mingw32/6.3.0/include/c++/mingw32",
                "g:/mingw/lib/gcc/mingw32/6.3.0/include/c++/backward",
                "g:/mingw/lib/gcc/mingw32/6.3.0/include/",
                "g:/mingw/include",
                "g:/mingw/lib/gcc/mingw32/6.3.0/include-fixed"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",
                "__GNUC__=6",
                "_cdecl=__attribute__((__cdecl__))"

            ],
            "windowsSdkVersion": "8.1",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                     "g:/mingw/lib/gcc/mingw32/6.3.0/include/",
                     "g:/mingw/lib/gcc/mingw32/6.3.0/include-fixed",
                     "g:/mingw/include/*"
                ]
            }
        }
    ],
    "version": 4
}

 里面的MinGW的路径要根据你自己电脑上的路径添加,前面的路径要修改,后面的不要修改(如果使用的是MinGW的话)

添加完成后保存就行了。

 

 参考文章:

https://www.jianshu.com/p/8933ebdac814

https://blog.csdn.net/feynman1999/article/details/79437524