Go Down

Topic: #include documentation (Read 2 times) previous topic - next topic

pYro_65

I read some of your other thread:

Quote
The Arduino IDE doesn't seem to have a problem finding the .h files since it opens them up in separate tabs with the sketch window automatically when I open the sketch.


This means they are in your sketch directory. In this situation you must use quotes, i.e:
Code: [Select]

#include "MySketchDirFile.h"


Brackets: '<' and '>' are used to specify common files, or in the IDE's case files that are accessible to other sketches.

Code: [Select]

#include <LibraryHeader.h>


The IDE does non standard things which enforces the use of <>.
When compiling the IDE copies your sketch files and any other files specified in '#include <>' to a temporary folder for compilation.

So ensure all libraries are included using <>, and even more so, you must include any libraries that your libraries include ( strange I know ).
This is to ensure that the files your libraries use are copied to the temporary directory.

mspohr

So... I'm afraid I'm still confused.
I have the .h in " " since they are in the same directory but they don't seem to be recognized by the compiler... so I assume that the "non-standard" stuff requires the use of < > but it doesn't seem to work with these either.

Should I use both?

#include <"OneWire.h">  ???

wanderson

Effectively it doesn't matter if you use "" or <>

The problem is that you have placed these files in the wrong place.  See my answer in either of your threads for instructions on how to fix that problem (or the reference manual for libraries).
New true random number library available at: http://code.google.com/p/avr-hardware-random-number-generation/

Current version 1.0.1

pYro_65

Libraries don't belong in your sketch directory.
Remove all files that aren't part of your sketch out of the sketch folder ( libraries ).

Place libraries in the libraries folder, if you have them there already, just delete all the copies you made elsewhere.

Quote
Should I use both?

#include <"OneWire.h">  ???

No that is wrong.
Do not use <> for files in your sketch directory, and do not put libraries in your sketch directory either.

mspohr

It seems to me that there should be some straightforward way to handle #include but I am having a very difficult time figuring it out and the documentation is very sparse.

So far, very helpful people have told me that I need to have a "libraries" folder in the same folder as my sketches.  So on my Mac, the Arduino IDE puts my sketches in a folder: Documents/Arduino
I have my sketches in this folder... the first is a sample project "Alarm" which is in: Documents/Arduino/Alarm
I created a folder: Documents/Arduino/libraries
I put the OneWire .h files in: Documents/Arduino/libraries/OneWire
I have these lines in the "Alarm" sketch:

#include <OneWire/OneWire.h>
#include <OneWire/DallasTemperature.h>

From what I have been told, this should work, but it doesn't.  I get these errors:
Alarm:1: error: variable or field 'printAddress' declared void
Alarm:1: error: 'DeviceAddress' was not declared in this scope
Alarm:2: error: variable or field 'printTemperature' declared void
Alarm:2: error: 'DeviceAddress' was not declared in this scope
... etc.

Is there some clear, complete documentation somewhere on how to use the #include ?

Go Up