如何将 C 库用于 Arduino 代码
How to use C Libraries for Arduino code
我在 Visual studio 中有一段代码想在 Arduino 中实现。但有一个问题。许多在 Visual Studio 中可用的库在 Arduino IDE 中不可用。我如何在我的 Arduino 代码中使用它们。准确地说,我要使用的库是
#include <iostream>
#include <iomanip>
#include <queue>
#include <string>
#include <math.h>
#include <ctime>
分别。
好的,我知道我在 Arduino 中有 <iostream>
可用。我认为 <math.h>
也可以与 <string>
库一起使用。
主要问题是如何使用 #include <queue>
及其功能,例如 priority_queue()
和 iostream
的其他功能,例如 .pop()
?
这里有详细介绍:
https://www.arduino.cc/en/Hacking/BuildProcess
The include path includes the sketch's directory, the target directory
(/hardware/core//) and the avr include directory
(/hardware/tools/avr/avr/include/), as well as any library
directories (in /hardware/libraries/) which contain a header
file which is included by the main sketch file.
这些是 avr-gcc(Arduino 使用的编译器)支持的库
Arduino 在后台使用 avr-gcc 编译器,它提供对 C++ 语言的许多功能的支持。但是,它不包括 libstdc++ 的实现,这意味着您习惯于在其他开发环境中拥有的许多库和功能并不存在。一个很大的原因是在小型微控制器上实现某些功能是不切实际的。
有几个可用的库可以实现您要使用的某些函数和数据结构的简化版本。您可以在此处找到这些库的列表(但不一定是完整的列表):
http://playground.arduino.cc/Main/LibraryList
例如 QueueList 可能是 <queue>
的一个很好的替代品。
无论您发现什么,您都可能需要重构代码才能使用它们。当您 运行 遇到实施这些库和更改的问题时,我建议您前往 https://arduino.stackexchange.com/ 以获得更多关于 arduino 的特定答案。
我在 Visual studio 中有一段代码想在 Arduino 中实现。但有一个问题。许多在 Visual Studio 中可用的库在 Arduino IDE 中不可用。我如何在我的 Arduino 代码中使用它们。准确地说,我要使用的库是
#include <iostream>
#include <iomanip>
#include <queue>
#include <string>
#include <math.h>
#include <ctime>
分别。
好的,我知道我在 Arduino 中有 <iostream>
可用。我认为 <math.h>
也可以与 <string>
库一起使用。
主要问题是如何使用 #include <queue>
及其功能,例如 priority_queue()
和 iostream
的其他功能,例如 .pop()
?
这里有详细介绍:
https://www.arduino.cc/en/Hacking/BuildProcess
The include path includes the sketch's directory, the target directory (/hardware/core//) and the avr include directory (/hardware/tools/avr/avr/include/), as well as any library directories (in /hardware/libraries/) which contain a header file which is included by the main sketch file.
这些是 avr-gcc(Arduino 使用的编译器)支持的库
Arduino 在后台使用 avr-gcc 编译器,它提供对 C++ 语言的许多功能的支持。但是,它不包括 libstdc++ 的实现,这意味着您习惯于在其他开发环境中拥有的许多库和功能并不存在。一个很大的原因是在小型微控制器上实现某些功能是不切实际的。
有几个可用的库可以实现您要使用的某些函数和数据结构的简化版本。您可以在此处找到这些库的列表(但不一定是完整的列表):
http://playground.arduino.cc/Main/LibraryList
例如 QueueList 可能是 <queue>
的一个很好的替代品。
无论您发现什么,您都可能需要重构代码才能使用它们。当您 运行 遇到实施这些库和更改的问题时,我建议您前往 https://arduino.stackexchange.com/ 以获得更多关于 arduino 的特定答案。