我正在尝试在代码中包含多个hpp文件,但是c_cpp_properties.json中的include path选项似乎无法正常工作。即使有正确的文件,我仍然收到“没有这样的文件或目录...”。
我已将路径添加到c_cpp_properties.json文件的includePath部分,但仍找不到文件。
包含主文件的一部分:
#include <iostream>
#include<conio.h>
#include <D:\OpenCV\opencv\build\include\opencv2\core\core.hpp>
#include <D:\OpenCV\opencv\build\include\opencv2\highgui.hpp>
#include <D:\OpenCV\opencv\build\include\opencv2\imgproc\imgproc.hpp>
c_cpp_properties.json文件:
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"D:/OpenCV/opencv/build/include",
"D:/OpenCV/opencv/sources/modules/core/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64"
}
],
"version": 4
}```
The file should run, but this error is causing it not to.
答案 0 :(得分:1)
如果c_cpp_properties.json
包含编译时使用的属性,则您的#include
可能看起来像这样:
#include <iostream>
#include <conio.h>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include
中的单个反斜杠很可能被解释为escape sequences的开始,这不会导致正确的路径。