-->
Page 1 of 2

'localtime' was not declared in this scope

PostPosted: Thu Aug 16, 2018 10:19 am
by drifterz28
I am working with an esp8266 NodeMcu 1.0 building a 2 zone sprinkler system, I had everything working and wanted to make some code changes to it but one day I started getting this error
Code: Select all'localtime' was not declared in this scope


for time I am using these 3 libraries in my sketch
Code: Select all#include <NTPClient.h>
#include <Time.h>
#include <TimeLib.h>


I have am unsure about what has changed in any of those includes and wanted to know if anyone else is having this issue or has come across something like it.

full code can be found at https://github.com/drifterz28/sprinkler ... -sprinkler

Re: 'localtime' was not declared in this scope

PostPosted: Thu Aug 16, 2018 3:43 pm
by btidey
I thought localtime was declared in time.h

In TimeLib.h there is a similar function called breakTime

Have you removed time.h from the includes?

Re: 'localtime' was not declared in this scope

PostPosted: Thu Aug 16, 2018 9:38 pm
by drifterz28
Yeah I did try removing each lib in question and I also checked the change log from the git commits of the code and did not see any changes. I think I will take some more time and look thru the code to see and maybe try breakTime.

Re: 'localtime' was not declared in this scope

PostPosted: Fri Aug 17, 2018 2:37 am
by btidey
Note that time.h is not the same as Time.h

time.h has the definition of localtime. Time.h just loads TimeLib.h which does not include localtime.

It is possible that something else in your code was loading time.h before.

You could try adding the include for time.h as well as the others.