Go Down

Topic: Can I include a header file that is not a library? (Read 66466 times) previous topic - next topic

wolffan69

I am transitioning from programming AVR chips in C to using an Arduino platform.  I used to include header files with the following syntax:

#include "file.h"

instead of a library which would be:

#include <library.h>

If I was just including a header file, I didn't have to create a library with source files.  The header file basically contained definitions that I didn't want to rewrite in the c code every time.

So, in the Arduino environment, can I include a header file that is not part of a library?

Coding Badly

#1
Jan 04, 2010, 07:18 am Last Edit: Jan 04, 2010, 07:20 am by bcook Reason: 1

If the include file is part of a single Sketch, instructions are here...
http://www.arduino.cc/en/Hacking/BuildProcess

If the include file is meant to be shared by multiple Sketches then...

  • Close the Arduino IDE
  • Navigate to the {Arduino}\hardware\libraries directory
  • Create a subdirectory.  I suggest something like MyCommon.
  • In the new subdirectory, create a header file.  I suggest something like MyCommon.h.
  • Open the new header file, edit it as you wish, and save it
  • Open the Arduino IDE
  • Create or open a Sketch
  • Add a #include to the top of the Sketch that references your new include file


wolffan69

Perfect!  Thanks for the reply.  That is exactly what I was looking for.

Go Up