我正在尝试使用带有 VSC 扩展Code Runner的ArduinoJson库运行程序,但我无法编译它。
VSC 中没有标记错误或警告,但是当我尝试运行此代码段时:
#include "../External_Libraries/ArduinoJson/ArduinoJson.h"
#include <iostream>
int main(){
std::cout << "Done.\n";
return 0;}
我得到下面的错误输出:
In file included from ../External_Libraries/ArduinoJson/src/ArduinoJson.hpp:17,\
from ../External_Libraries/ArduinoJson/src/ArduinoJson.h:9,\
from ../External_Libraries/ArduinoJson/ArduinoJson.h:5,\
from localtest.cpp:17:\ ../External_Libraries/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp:7:10: fatal error:\ ArduinoJson/Array/ArrayFunctions.hpp: No such file or directory\
#include <ArduinoJson/Array/ArrayFunctions.hpp>\
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ compilation terminated.
在 ArduinoJson 库中,有一些使用双引号的包含命令和一些使用尖括号的命令:
#include "src/ArduinoJson.h"
//...
#include <ArduinoJson/Array/ArrayFunctions.hpp>
似乎只有带有尖括号的包含语句是一个问题。我已经尝试在 settings.json 以及 c_cpp_properties.json 中更新我的包含路径以涵盖这一点,但它没有奏效:
在 settings.json 中:
"C_Cpp.default.includePath": [
"C:\\...\\project",
"C:\\...\\project\\External_Libraries\\ArduinoJson\\src",
"C:\\...\\project\\External_Libraries\\ArduinoJson\\src\\ArduinoJson\\Array"],
"C_Cpp.default.compilerPath": "C:\\MinGW\\bin\\gcc.exe"
在 c_cpp_properties.json 中:
"name": "Win32",
"includePath":[
"${default}",
"C:/.../project",
"C:/.../project/External_Libraries/ArduinoJson/src/ArduinoJson/Array"],
"defines":[
"_DEBUG",
"UNICODE",
"_UNICODE"],
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "windows-gcc-x86",
"compilerPath": "C:/MinGW/bin/gcc.exe",
"compilerArgs": ["-I C:\\...\\project\\External_Libraries"]
有谁知道我可能做错了什么?
我的文件夹结构是
项目/
--src/
----localtest.cpp --External_Libraries
/
----ArduinoJson/