Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumProgramming Questions & HelpSyntax › How to include header file to sketch?

Page Index Toggle Pages: 1
How to include header file to sketch? (Read 3658 times)
02/04/09 at 20:27:52

redman   Offline
YaBB Newbies

Posts: 8
*
 
Hi all,

I have this situation:

1 project file.
1 .h file with globally defined structs/types.
1 .cpp file with global functions.

If i try to declare a variable of my type within setup() the compiler doesnt know the type (or type is out of scope).

But if i try to include the header file in the project then i get double declaration errors. So it is already known.

Also, if i declare this struct globally in the project file then it works (but i want to keep the project file tidy and clean)

So my question is how can i add a header file to the project .
Or, how do i split the project file to make it more manageble.
 
IP Logged
 
Reply #1 - 02/10/09 at 03:17:12

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
Go to your Wiring isntallation folder inside libraries and create a floder for your library, you can look inside and see the libraries included in the distribution, put your files in there, and your library will be compiled when you press the play button the next time in the editor. From now on you can use the #include <yourinclude.h> directive in your sketch to include your library, or go to the Sketch -> Import library menu and select your library. Let me know.
 
IP Logged
 
Reply #2 - 02/11/09 at 12:01:43

redman   Offline
YaBB Newbies

Posts: 8
*
 
Aah, thank you.

It seems to be working now.
But now the library is outside the IDE.
I need to manualy delete the .o file before i can compile it.
Usualy this is not a big problem, but i'm not a very good programmer, so i need to test a lot, so i compile a lot. Smiley

So maybe this is something for the next release? :
Option to force re-compile of libraries when you do a normal compile.
 
IP Logged
 
Page Index Toggle Pages: 1