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
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:
## 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
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include
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!