Yes, if the header file defines something unique. (Most do so in their guard code.)
In other words, most headers will have the form:
So you would put the following in your code:
// Must be using SomeUniqueThing library
If they don't have that, you can look through the header for a #define that is "pretty unique" to that header and test for that. Failing that, I don't know any other easy way. Be wary of different versions of the same libraries, too.
Doh!! Wire library uses TwoWire_h no wonder it wasn’t working. Thanks AndyCC.
Er, how will that work exactly? Say you include the library, eg.
Then you know you included it, right? But if you don’t include it, there is no point in testing for some define inside it.
I probably didn’t explain it well enough. I’m making a library for an I2C device so when it’s included it will check to see if the person is using Wire or my I2C library. The functions are completely different between the two. I also need a check in place to make sure they didn’t include both libraries because if they somehow did the I2C wouldn’t function right because I shut off interrupts inside it.