PaulStoffregen / Time

Time library for Arduino
http://playground.arduino.cc/code/time
1.25k stars 666 forks source link

Issue compiling on ESP32 with latest ESP32 library (2.0.6) #176

Open wrybread opened 1 year ago

wrybread commented 1 year ago

After updating my ESP32 library for the Arduino IDE (using Windows) from version 1.0.6 to 2.0.6 (latest), I could no longer compile, and I received cryptic error messages that pointed to another library, esp32time. Unfortunately I didn't save the error messages, but I can revert my changes below if they're needed.

After doing some research I found that Time.h may get used instead of time.h on Windows, since it's a case insensitive OS.

Inisde this timezone library's folder I found Time.h and Time.cpp, and I renamed them to Time2.h and Time2.cpp and then my script would compile.

Interestingly the timezone library seems to still be working fine. I'm able to set the timezone, and it translates GMT time to my local timezone. If there's a problem I haven't found it yet.

Also in TimeLib.h I found this note:

// This ugly hack allows us to define C++ overloaded functions, when included
// from within an extern "C", as newlib's sys/stat.h does.  Actually it is
// intended to include "time.h" from the C library (on ARM, but AVR does not
// have that file at all).  On Mac and Windows, the compiler will find this
// "Time.h" instead of the C library "time.h", so we may cause other weird
// and unpredictable effects by conflicting with the C library header "time.h",
// but at least this hack lets us define C++ functions as intended.  Hopefully
// nothing too terrible will result from overriding the C library header?!

Related?

Anyway, I'm wondering if I've likely broken anything with this "fix"? And is there a better fix I could apply to get this compile on ESP32?

Thanks for any help.