Problem with ESP32Time.h

Hello forum,

my code in total has meanwhile over 2500 lines, so I not try to post this here.
Imagine the following:
one single instance of IDE is running with 2 codes.
Both codes have the

#include <ESP32Time.h>
ESP32Time rtc;

before the Setup().
Both codes have roughly the same size.
Code 1 is compiling perfectly.
Code 2 gives an error:

In file included from C:....sketchbook\CY\CY_Touch\CY-Touch_New_5.40\CY-Touch_New_5.40.ino:63:0:
C:.....sketchbook\libraries\ESP32Time/ESP32Time.h:30:1: error: expected '}' before 'class'
 class ESP32Time {
 ^
C:....\sketchbook\libraries\ESP32Time/ESP32Time.h:30:1: error: expected ',' or ';' before 'class'
CY-Touch_New_5.40:139:1: error: 'ESP32Time' does not name a type
 ESP32Time rtc;
 ^

Both codes are using the same ESP32Time.h library.
I checked since hours all the modifications I made for possible errors like forgotten "}" os something.
Do you have an idea to point me in the right direction?
As the errormessage says an Error in the library code I do not expect an error in the main code?

Best regards

Agreed, nobody wants to see that.

Instead, post an MRE. This is the smallest possible, complete example code that demonstrates the problem at hand.

BTW, there's no need to use ANY external time library to work with the ESP32's RTC. It natively supports the full set of POSIX time commands and provides native APIs for synching time with NTP.

Looking at that file, on line 30, that class line is the first bit of actual C++ code in the file. Before it is a giant comment /* */ and a few preprocessor directives #. At compile-time, those "vanish" in the eyes of the compiler.

It's complaining that whatever came before it is not correctly terminated. What is before the

If it is another included file, what is at the end of that? You could even try adding something

int placeholder;
#include <ESP32Time.h>

And you should get a slightly different error. The problem is not with ESP32Time.h

1 Like

kenb4 is right.

When I try this example: https://github.com/fbiego/ESP32Time/blob/main/examples/esp32_time/esp32_time.ino
in Wokwi simulation on a ESP32, then it runs without problem.

We don't mind reading 2500 code lines. That is not a big sketch.

It's unlikely the bug is in the library code, it will be in a statement a line or two in front of or behind the include

Hi all and greetings,
first of all: thanks for your thoughts.

What I didn't mentioned, there is a quite long list of libraries included plus a usergraphics.h

#include "usergraphics.h"
#include <ESP32Time.h>

Now, both codes have the excat same definition part, BUT: the "usergraphics.h" will be copied always when I saved a new version in the sketchbook (what I forgot). And I modified this usergraphics.h and in there I forgot the last "}".

After I commented the new additional subroutines, the error pointed to the graphic tft.draw command, one grapic wasn't defined.
That was the hint.
Again many thanks for your toughts.
Sometimes one need a little "push" from the side.
Regards