Closed PatrickDekker98 closed 2 years ago
Any more details on why this happens? Does ArduinoCore-samd define its own version of the Udp class somehow and using the same include guards on both ensures only one of them is added? If so, I think that would be fragile, since depending on include ordering you might get one or the other definition?
https://github.com/arduino/ArduinoCore-samd/blob/master/cores/arduino/Udp.h ArduinoCore-samd defines its own Udp class, which is functionaly the same as the one in core-api except it uses include guards instead of #pragma once
Sounds like this is really a bug in ArduinoCore-samd and that the Udp.h should be removed from there?
I just checked, core-stm32 and core-avr have the same problem. Of course deleting it in arduino-core would be the most efficient but I am not sure what problems that could cause.
I just checked, core-stm32 and core-avr have the same problem.
I think those other two cores do not include ArduinoCore-API yet (they just duplicate everything, from before ArduinoCore-API existed).
When you say "the same problem", do you mean you get the same errors? Or just that they contain an Udp.h (since the latter is to be expected)?
Of course deleting it in arduino-core would be the most efficient but I am not sure what problems that could cause.
Seems like that would be the proper solution here, and if the include paths are set up correctly so #include <Udp.h>
still works, I would not expect any problems here. Maybe you could report an issue in that repo and close this one?
I think those other two cores do not include ArduinoCore-API yet (they just duplicate everything, from before ArduinoCore-API existed). When you say "the same problem", do you mean you get the same errors? Or just that they contain an Udp.h (since the latter is to be expected)?
They both contain an Udp.h if you say that is to be expected I trust you. I'm not sure what arduino's design decisions where or are. To me It would seem that Udp.h is hardware independent so it should probaply be in Arduino-core. I'll close this issue
I'm not sure what arduino's design decisions where or are.
It's just that originally ArduinoCore-API did not exist and each core would duplicate all hardware-independent code. Then Arduino-Core-API was invented to house all this independent code, but not all cores have been modified to include ArduinoCore-API yet, so at least the AVR core still contains all of the independent code directly, instead of including ArduinoCore-API, which is why it is expected that Udp.h is in there, but not in ArduinoCore-samd.
https://github.com/arduino/ArduinoCore-API/blob/e26862e453c1234e1c23506d1839bfa68999d911/api/Udp.h#L35
Pragma once instead of include guards causes
error: redefinition of 'class arduino::UDP'
with the ArduinoCore-samd.An easy fix would be to add:
Or remove the double class definition