I have a problem when I try to get the local time using the standard ESP32 function
getLocalTime. The following error appears:
error: aggregate ‘tm timeinfo’ has incomplete type and cannot be
Steps To Reproduce Problem
The problem can be reproduced by writing the following code with the installed TimeAlarms library.
struct tm timeinfo;
Serial.println("Failed to obtain time");
It seems like this problem is not present in Linux as far I can see.
Hardware & Software
Board: ESP32 DevKit V4
Arduino IDE version: Platformio, PLATFORM: Espressif 32 (1.12.4) > DOIT ESP32 DEVKIT V1
Operating system & version: Windows 10
lib_ignore = Time in the
platformio.ini does not help?
@maxgerhardt I already tried that, it didn’t help because in that case I got the following error:
.pio\libdeps\esp32doit-devkit-v1\TimeAlarms/TimeAlarms.h:7:21: fatal error: TimeLib.h: No such file or directory
Okay then remove
lib_ignore = Time again
this folder should have a
Time.h file. Delete it. The Windows file system should then find the
time.h of the compiler instead of the
Time.h of that library.
Thank you, it works now. It would be nice if you (or some of developers) can make this library work without need for this kind of manual changes.
The main issue here is that the library
Time was published once by PaulStoffregen (GitHub - PaulStoffregen/Time: Time library for Arduino) and it contains the
Time.h library which makes so much problems on Windows which has a case-insensitive filesystem and if the compiler-builtin
time.h standard library is supposed to be used too – And since some libraries built on that do a
#include <Time.h> still instead of
TimeLib.h it’s difficult to just release a library without the
For a more permanent and portable solution, please do the following:
- Close VSCode
- Copy the folder
lib/ (so that it becomes
- Remove the
Time.h file from inside
- Remove the
- Re-Open VSCode and rebuild
If all goes right it should now source the “Time” library from the
lib/ folder which has the offending file removed and it should all still compile.
@maxgerhardt I will do that, thank you.