是否可以使用 Arduino IDE 包含来自另一个库的库?

2022-01-25 00:00:00 ide arduino include c++

I'm trying to write an Arduino library (effectively a C++ class) which itself references another library I have installed in my Mac's ~/Documents/Arduino/libraries directory.

At the top of the .cpp of the library I'm writing, I've tried

#include <ReferencedLibrary.h>

and

#include "ReferencedLibrary.h"

... neither of which work. I can successfully #include <ReferencedLibrary.h> from sketches in my ~/Documents/Arduino directory. Am I missing something or is this a limitation of the Arduino IDE/makefile? Is there a workaround?

解决方案

This issue was solved in the Arduino 1.6.6 release. The release notes of 1.6.6 mention that library to library dependencies have been fixed.

Library to library dependencies: when your sketch imports a library, and that library uses another, the IDE will find out without you having to add a useless #include to your sketch

Updating your version to 1.6.6 or newer will resolve your problem.

相关文章