Calling a library twice

I'm using an I2C LCD library that calls wire.h without it needing to be done separately.
As I will be using I2C for more than just the LCD, and I may not use the same type of display in the long term, it is useful to have the wire.h called outside the LCD's library. That way I don't have to remember to put it back in if I take out the LCD library.

Are there any consequences of the wire.h library being called twice?

Are there any consequences of the wire.h library being called twice?

If you mean are there any consequences of #including it twice, then no, not if is written correctly

Wire.h has the following guard code in it

#ifndef TwoWire_h
#define TwoWire_h
//library code here
#endif

so if the library has already been #included then subsequent #includes are ignored

This is common practice with libraries but cannot be guaranteed to have been used in all cases

Include guard.

Good news. Thanks for the help.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.