Identifier is undefined - setenv tzset

Code like

#include <time.h>
#include <cstdlib>

void setup() {
    setenv( "TZ", "PST8PDT", 1 );
    tzset(); 
}

void loop() {}

does compile and is advertised to work by the underlying ESP-IDF layer.

There is just an Intellisense error, which comes from the fact that there are multiple time.h files in the include path of the compiler and that a macro is set which comments out the definition of those functions.

Same for setenv()

And __STRICT_ANSI__ is defined by the compiler in the Intellisense, but obviously the /tools/sdk/lib/libc_nano.a contains the definitions so it was compiled without the strict ANSI.

Not sure how to put the compiler during Intellisense into the mode so that __STRICT_ANSI__ is not defined and these extended functions are compiled in. If you just want to get rid of the Intellisense errors you can copy-paste the declaration on top of the sketch.

#include <Arduino.h>

_VOID      _EXFUN(tzset,	(_VOID));
int	_EXFUN(setenv,(const char *__string, const char *__value, int __overwrite));
2 Likes