Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example doesn't compile because Time.h #96

Closed
ssaguiar opened this issue Nov 19, 2016 · 5 comments
Closed

Example doesn't compile because Time.h #96

ssaguiar opened this issue Nov 19, 2016 · 5 comments
Labels

Comments

@ssaguiar
Copy link

Your example doesn't compile:

I am using PlatformIO to compile:

Processing nodemcuv2 (platform: espressif8266, lib_deps: ESPAsyncTCP, board: n
odemcuv2, framework: arduino)
.
.
.
.
lib\ESPAsyncWebServer\src\WebHandlers.cpp: In member function 'AsyncStaticWebHandler& AsyncStaticW
ebHandler::setLastModified(tm*)':
lib\ESPAsyncWebServer\src\WebHandlers.cpp:67:64: error: 'strftime' was not declared in this scope
strftime (result,30,"%a, %d %b %Y %H:%M:%S %Z", last_modified);

^
lib\ESPAsyncWebServer\src\WebHandlers.cpp: In member function 'AsyncStaticWebHandler& AsyncStaticW
ebHandler::setLastModified(time_t)':
lib\ESPAsyncWebServer\src\WebHandlers.cpp:72:60: error: 'gmtime' was not declared in this scope
return setLastModified((struct tm *)gmtime(&last_modified));
^
lib\ESPAsyncWebServer\src\WebHandlers.cpp: In member function 'AsyncStaticWebHandler& AsyncStaticW
ebHandler::setLastModified()':
lib\ESPAsyncWebServer\src\WebHandlers.cpp:77:25: error: 'time' was not declared in this scope
if(time(&last_modified) == 0) //time is not yet set
^
*** [.pioenvs\nodemcuv2\lib\ESPAsyncWebServer\WebHandlers.o] Error 1
[ERROR] Took 97.28 seconds

Any ideas?

@ghost
Copy link

ghost commented Jan 17, 2017

I had similar issues with some incompatible time libraries.
If you use the preferred Time library (https://github.com/PaulStoffregen/Time) you can use
#include Timelib.h
instead of Time.h
The time library uses an header file with an uppercase T, while there are some other time.h with an lower-case t from other projects.
OSses like Windows and Mac don't make an difference there :-(

@jamesmyatt
Copy link

I have this problem also, on windows only, not linux. I solved it by deleting the "Time.h" from the Time library (https://github.com/PaulStoffregen/Time), and using TimeLib.h only in my code.

@igrowing
Copy link

igrowing commented Dec 8, 2018

This compilation problem happens in Windows only. Linux and Mac are case sensitive for files, so these OSes differ between time.h and Time.h. Windows doesn't.
The problem comes when Time_ID44 lib in installed (that's often used lib) and ESPAsyncWebServer_ID306 lib includes time.h in WebHandlerImpl.h.
So wrong time lib is included due to OS case insensitivity.
There is advice to include TimeLib.h instead of time.h. Tried this, doesn't work.
Workaround that works:

  1. Rename the lib:
  • Go to: disk:\Users\username\.platformio\packages\toolchain-xtensa\xtensa-lx106-elf\include
  • Rename time.h to _time.h.
  1. Find all occurrences of WebHandlerImpl.h in your Windows. Replace #include <time.h> with #include <_time.h>
  2. Build your project. (Recommended restart platformio before the build).

@stale
Copy link

stale bot commented Sep 21, 2019

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 21, 2019
@stale
Copy link

stale bot commented Oct 5, 2019

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants