Pages: [1]   Go Down
Author Topic: including a contributed library in a library header  (Read 546 times)
0 Members and 1 Guest are viewing this topic.
Hamburg, Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,
I'm new to the forum and to Arduino development. I have gotten pretty far thanks to wealth of information here. I am sure this has been asked and answered before but I haven't been able to get the correct search phrase to find it, so excuse me for asking again.
I want to include a contributed library header in my library header. I have written a library named DS1821 for the same-named Maxim/Dallas Semi temperature sensor and want to include the OneWire library (my class inherits the OneWire class). Both libraries, my DS1821 and OneWire, are in the /Users/me/documents/Arduino/libraries directory (Mac OS X 10.6). Arduino is 1.0.1.

In my header, DS1821.h, I have the lines

#ifndef DS1821_h
#define DS1821_H
#include <OneWire.h>
. . .
#endif // DS1821_h

However, my application won't compile unless I include both headers.

#include <OneWire.h>
#include <DS1821.h>
. . .

While this works just fine, what should I do to not have to include the OneWire header in my application code?
Thanks for your help!
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

While this works just fine, what should I do to not have to include the OneWire header in my application code?

Nothing. Think of it as a form of documentation.
Logged

Hamburg, Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Nick, that was a quick answer! Thank you very much.
"Think of it as a form of documentation."
OK, that works for me!
- Totoro
Logged

UK
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3969
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Any libraries used within your library must also be included in the sketch your library is used in.

This is not a drawback of C++, but a drawback of the Arduino IDE.  The IDE has to know what libraries to link with the sketch to get it to work.  It cannot recurse down into the included libraries to see what libraries they rely on.

Yes, it sucks.  But that's the Arduino IDE for you.
Logged

Why not visit my eBay shop? http://stores.ebay.co.uk/Majenko-Technologies
Replacement for the Arduino IDE: UECIDE - Proper serial terminal, graphing facilities, plugins, overhauled internals.
Java isn't bad in itself, but it has enabled morons to write programs.

Pages: [1]   Go Up
Jump to: