I have created a library that interanlly uses the Wifi library and the SPI library.
My library works perfectly, but ONLY if you also write the #include statements for both of the other libraries in the main sketch.
I notice that when using the IDE to include libraries, with some it will automatically plop in multiple #include statements when you include one library.
Is it possible to make my library do this, so that when a user selects my library from the list Arduino also includes SPI.h and WiFi.h?
I am trying to prevent the case of someone trying to use my library, not including the others, and being confused at why they are getting an error.
I notice that when using the IDE to include libraries, with some it will automatically plop in multiple #include statements when you include one library.
No it does not. The only time any #includes are added is when the .ino is converted to a .cpp
You must include all the .h's that your lib needs in your .h/.cpp files.
Mark
holmes4:
No it does not. The only time any #includes are added is when the .ino is converted to a .cpp
You must include all the .h's that your lib needs in your .h/.cpp files.
Mark
Perhaps I didn't word this in a way that was logical. I'll give an example.
If I select WiFi from the IDE's list of libraries, in my code I do not only get:
#include <WiFi.h>
Instead I get:
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>
When I click my own library, I do not want to only get:
#include <mylibrary.h>
I would like to get:
#include <mylibrary.h>
#include <SPI.h>
#include <WiFi.h>