Time.h and NTP on ESP32

I’m developing with ESP32 boards, and I’d like to use NTP. This has been provided through ‘time.h’, and mostly works. It updates, and I have a callback

void ntpCallback(timeval*) {
  Serial.println("NTP UPDATED");
}

that I set with sntp_set_time_sync_notification_cb(ntpCallback);

However, sometimes, I get compiler errors that timeval is not defined, and sntp_set_time_sync_notification_cb is not defined. I can’t figure out when and why this happens - it was working fine, I moved some functionality around, now it doesn’t. If I walk into time.h with VS Code, it has found it in .platformio/packages/framework-arduinoespressif32/tools/sdk/include/newlib/time.h, and indeed it doesn’t have a struct timeval or sntp_set_time_sync_notification_cb.

Where does time.h come from, and what might I need to do to figure out getting the right version going on?

time.h is a standard C library header. The sntp functions come from the LWIP stack. Judging from

you need at least these 3 includes.

There’s also a caveat that someone created a popular library with the header name Time.h, which causes conflicts with the standard time.h header on systems with case-insensitive filesystems (such as Windows). To prevent this library from being included, you can add lib_ignore = Time. But I don’t thik that’s the case here, otherwise compilation would always fail and not “sometimes”.

Ah, that’s great, thanks! Adding #include "sntp.h" worked. There seems to be a bunch of code floating around that doesn’t have the sntp.h include - it might be the case that this is included somewhere else, and that would be why it’s happy in some files and not others, I guess.