2

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.

dda
1,5951 gold badge12 silver badges17 bronze badges
asked May 23, 2017 at 3:50
2
  • > Can I include a header file into a new header file that I created? Yeah. That's what they are meant to be used. Commented 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... Commented Sep 22, 2017 at 12:49

2 Answers 2

3

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

answered May 23, 2017 at 7:29
2

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.

answered May 23, 2017 at 4:02
5
  • 3
    Wouldn't it have been easier to just try it to begin with instead of asking and waiting? Commented May 23, 2017 at 4:40
  • i want to llink MCP23S17.h file to my own created header file Commented May 23, 2017 at 4:41
  • can you give some suggestion to it Commented May 23, 2017 at 4:42
  • Suggestion to what? Commented 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. Commented Dec 20, 2017 at 4:40

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.