Can I include a header file into a new header file that I created? I put #include <MCP23S17.h>. I want to create a another header file.

  • > Can I include a header file into a new header file that I created? Yeah. That's what they are meant to be used.
    – dannyf
    May 23, 2017 at 16:48
  • 2
    Just remember to put Include guards to avoid problems... And remember to accept the most useful answer to avoid being bumped to the homepage uselessly...
    – frarugi87
    Sep 22, 2017 at 12:49

2 Answers 2


Why not just include both in the final program?

Happens all the time.

DHT.h needs AdaFruit_Sensor.h, for instance, so you just include both.

First AdaFruit then DHT


Yes, a header can include another header. But if you are using the Arduino IDE and the headers aren't in the same folder, then you'll also need an #include line for it in the .ino file.

  • 3
    Wouldn't it have been easier to just try it to begin with instead of asking and waiting?
    – Delta_G
    May 23, 2017 at 4:40
  • i want to llink MCP23S17.h file to my own created header file May 23, 2017 at 4:41
  • can you give some suggestion to it May 23, 2017 at 4:42
  • Suggestion to what?
    – Delta_G
    May 23, 2017 at 4:45
  • 1
    Since Arduino IDE 1.6.6 it's no longer necessary to add includes to the sketch for library-library dependencies.
    – per1234
    Dec 20, 2017 at 4:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.