Home  >  Article  >  Development Tools  >  Solve the problem that vscode cannot find the c++ header file under windows

Solve the problem that vscode cannot find the c++ header file under windows

王林
王林Original
2019-12-30 09:37:4319907browse

Solve the problem that vscode cannot find the c++ header file under windows

The problem that vscode cannot find the header file is because the default compiler of vscode under windows is the header file path of Microsoft's MSVC (the compiler used by vscode).

If you have not installed vs, you will definitely get an error because the header file cannot be found. If you install vs, you will get the same error. The reasons are as follows:

1. You have misconfigured the vscode configuration file;

2. You used a header file that does not exist in the MSVC header file library, such as bits/stdc .h

Solution:

1. Modify the configuration File;

2. Copy the required header files to the header file path of vs

If the computer does not have vs installed and the mingw series is installed, it can only be solved by modifying the configuration file.

1. How to modify the configuration file:

Create a new c_cpp_properties.json file in the .vscode folder

Solve the problem that vscode cannot find the c++ header file under windows

Paste the following code into it. Among them, change the includePath option to the lib/gcc/x86_64-w64-mingw32/8.1.0/include folder path

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "C:/Program Files/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "intelliSenseMode": "gcc-x64"
        }
    ],
    "version": 4
}

for non- For header files in the standard library, the path can also be appended to includePath through list appending

For example:

Solve the problem that vscode cannot find the c++ header file under windows

## 2. Modification Header file method:

First you must install one of the Microsoft vs series, such as:

visual stdio 2017 Community, and then find the header file path under the installation path

The default is:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include

Solve the problem that vscode cannot find the c++ header file under windows

Then paste the header files you need into this folder, so that MSVC and mingw have the same header file library.

Recommended related articles and tutorials:

vscode tutorial

The above is the detailed content of Solve the problem that vscode cannot find the c++ header file under windows. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Is vscode open source?Next article:Is vscode open source?