Where is the default Arduino TwoWire constructor defined?

713 Views Asked by At

I'm a bit confused by something in the TwoWire Arduino library. The Wire.h and Wire.cpp files define a single constructor which requires three arguments: TwoWire::TwoWire(SERCOM * s, uint8_t pinSDA, uint8_t pinSCL).

Yet the Wire.h file instantiates a global instance with no arguments: extern TwoWire Wire; at the end of the file.

I was under the impression that once you explicitly define a constructor for a class, the C++ compiler wil not automatically create any default constructors.

So, where is the paramaterless TwoWire constructor defined?

And, how are the private variables sercom, _uc_pinSDA, and _uc_pinSCL initialized?

1

There are 1 best solutions below

0
David Patterson On BEST ANSWER

Thanks to @Juraj.

The extern declaration in Wire.h only indicates that Wire is defined somewhere, it doesn't define it.

It's actually defined at the end of Wire.cpp where the constructor is, indeed, called with three arguments.