gmag11 / ESPNtpClient

High accuracy NTP library for ESP32 and ESP8266
MIT License
118 stars 25 forks source link

ESPNtpClient won't compile with TimeLib.h #17

Closed morres83 closed 3 years ago

morres83 commented 3 years ago

Hello, I am facing the following issue: The ESPNtpClient doesn't compile on ESP32 as soon as the TimeLib.h (paulstoffregen/Time@^1.6) gets included. Unfortuneatly this library is a dependency of DS3232RTC.h which I also need. Without Time.h and TimeLib.h, there is no compiling error

Is there a workaround?

.pio/libdeps/nodemcu-32s/ESPNtpClient/src/ESPNtpClient.h:65:16: error: expected ')' before '(' token constexpr auto SECS_PER_MIN = ((time_t)(60UL));

.pio/libdeps/nodemcu-32s/ESPNtpClient/src/ESPNtpClient.h:66:16: error: expected ')' before '(' token constexpr auto SECS_PER_HOUR = ((time_t)(3600UL));

.pio/libdeps/nodemcu-32s/ESPNtpClient/src/ESPNtpClient.h:67:16: error: expected ')' before '(' token constexpr auto SECS_PER_DAY = ((time_t)(SECS_PER_HOUR * 24UL));

.pio/libdeps/nodemcu-32s/ESPNtpClient/src/ESPNtpClient.h:68:16: error: expected ')' before '(' token constexpr auto DAYS_PER_WEEK = ((time_t)(7UL));

.pio/libdeps/nodemcu-32s/ESPNtpClient/src/ESPNtpClient.h:69:16: error: expected ')' before '(' token constexpr auto SECS_PER_WEEK = ((time_t)(SECS_PER_DAY * DAYS_PER_WEEK));

.pio/libdeps/nodemcu-32s/ESPNtpClient/src/ESPNtpClient.h:70:16: error: expected ')' before '(' token constexpr auto SECS_PER_YEAR = ((time_t)(SECS_PER_DAY * 365UL));

.pio/libdeps/nodemcu-32s/ESPNtpClient/src/ESPNtpClient.h:71:16: error: expected ')' before '(' token constexpr auto SECS_YR_2000 = ((time_t)(946684800UL)); ///< @brief The time at the start of

morres83 commented 3 years ago

Actually the workaround is to just comment out these lines or wrap in into a

ifndef SECS_PER_MIN

...

endif

These items are already defined in Time.h as it seems.

gmag11 commented 3 years ago

That's a good solution. Would you add a pull request?

gmag11 commented 3 years ago

Fixed in 93ecd1b0ca7aaf7940d9319b2dd22b0cde63a128 https://github.com/gmag11/ESPNtpClient/releases/tag/0.2.5