Library within library

Hello everyone,

Today I tried to build a little library to manage many buttons. Within my button.cpp file I use a function(TIMER0_getTimeStamp) which comes from my home made Timer0 library. So in my button.h I include my timer0.h, and in my main since I do not need to explicitely use any of my timer0 functions I only include button.h.

I get an error message telling me that 'TIMER0_getTimeStamp' was not declared in this scope. After playing a bit with the include statements I found that if I include timer0 in my main everything works, but why is that?

I thought it was possible to include an use a library within an other library without having to define it in the main file?

Here is my include statements

main file :

#include <button.h>
#include <utils.h>
#include <uart.h>

button.h :

#ifndef BUTTON_H_
#define BUTTON_H_

#define true 1
#define false 0

#include <avr/io.h>
#include <avr/interrupt.h>
#include <timer0.h>

button.cpp

#include <button.h>

If my question is not clear enough I can paste all my code, but since it does not seem to relate to the code per say I did not include it for sake of shortness.

Thanks you all
M.

I thought it was possible to include an use a library within an other library without having to define it in the main file?

Well, now you know better. You can NOT hide the use of a library from the sketch.

Thanks for the answer!

Is it only within the arduino framework or it is a general programming principle?

M.

Hawk_08:
I get an error message telling me that 'TIMER0_getTimeStamp' was not declared in this scope. After playing a bit with the include statements I found that if I include timer0 in my main everything works, but why is that?

Because the IDE copies all your files (including libraries) to a temporary directory to compile them. It decides which to copy from the include directives in the main .ino file. That's why.

This is not a limitation in programming in general. However then you have the bother of setting up "projects" (usually) to tell the IDE which files to compile.