The code fragment below uses a custom library, and it used to work in Arduino 21, but no longer compiles in 22:
#include <DateTime.h>
inline unsigned long RtcSecondsSinceMidnight(const DateTime& now) {
unsigned long secs = (unsigned long)(now.hour()) * 3600UL +
(unsigned long)(now.minute()) * 60UL +
now.second();
return secs;
}
void loop() {
...
DateTime date_time_now = RTC.now();
unsigned long day_time = RtcSecondsSinceMidnight(date_time_now);
}
This compiled fine in Arduino 21. In version 22, I get:
MEGA_cbox:4: error: expected ',' or '...' before '&' token
MEGA_cbox:4: error: ISO C++ forbids declaration of 'DateTime' with no type
[also the line number is incorrect, refers to a comment.]
However, this compiles:
#include <DateTime.h>
// Use a global variable instead of passing as a param:
DateTime now;
inline unsigned long RtcSecondsSinceMidnight() {
unsigned long secs = (unsigned long)(now.hour()) * 3600UL +
(unsigned long)(now.minute()) * 60UL +
now.second();
return secs;
}
void loop() {
now = RTC.now();
unsigned long day_time = RtcSecondsSinceMidnight();
}