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

Compile error on FS.h: missing time.h import #6714

Closed
Niek opened this issue Nov 5, 2019 · 11 comments
Closed

Compile error on FS.h: missing time.h import #6714

Niek opened this issue Nov 5, 2019 · 11 comments

Comments

@Niek
Copy link
Contributor

Niek commented Nov 5, 2019

See 72dd589#r35810441: that commit breaks compilation for me because a <time.h> include is missing:

xtensa-lx106-elf-g++ -o .pio/build/myenv/libf93/ESP8266WiFi/ESP8266WiFiMulti.cpp.o -c -fno-rtti -std=c++11 -g -w -Os -mlongcalls -mtext-section-literals -falign-functions=4 -U__STRICT_ANSI__ -ffunction-sections -fdata-sections -fno-exceptions -Wall -DPLATFORMIO=40003 -DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP01 -DMQTT_MAX_PACKET_SIZE=1024 -DNO_GLOBAL_EEPROM -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY_LOW_FLASH -DBEARSSL_SSL_BASIC -DUSE_CUSTOM_H -DSECURE_CLIENT=SECURE_CLIENT_BEARSSL -DF_CPU=80000000L -D__ets__ -DICACHE_FLASH -DARDUINO=10805 -DARDUINO_BOARD=\"PLATFORMIO_ESP01_1M\" -DFLASHMODE_DOUT -DLWIP_OPEN_SRC -DNONOSDK22x_190703=1 -DTCP_MSS=536 -DLWIP_FEATURES=0 -DLWIP_IPV6=0 -DVTABLES_IN_FLASH -I~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/libraries/ESP8266WiFi/src -I.pio/build/myenv/core -I~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/tools/sdk/include -I~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/tools/sdk/libc/xtensa-lx106-elf/include -I~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266 -I~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/tools/sdk/lwip2/include -I~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/variants/generic ~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp
In file included from ~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/libraries/ESP8266WiFi/src/CertStoreBearSSL.h:26:0,
                 from ~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/libraries/ESP8266WiFi/src/WiFiClientSecureBearSSL.h:30,
                 from ~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/libraries/ESP8266WiFi/src/WiFiClientSecure.h:41,
                 from ~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/libraries/ESP8266WiFi/src/WiFiServerSecure.h:20,
                 from ~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/libraries/ESP8266WiFi/src/ESP8266WiFi.h:41
~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/FS.h: In static member function 'static time_t fs::FS::_defaultTimeCB()':
~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/cores/esp8266/FS.h:244:58: error: 'time' was not declared in this scope
     static time_t _defaultTimeCB(void) { return time(NULL); }
                                                          ^

Simply adding #include <time.h> to FS.h doesn't resolve the issue, seemingly because it includes the wrong header file. Adding #include "~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/tools/sdk/libc/xtensa-lx106-elf/include/time.h" or #include "../../tools/sdk/libc/xtensa-lx106-elf/include/time.h" does work, but that doesn't seem like a good solution. Any ideas?

Niek referenced this issue Nov 5, 2019
* Add time to filesystem API

Support the ESP32 File::getLastWrite() call and setting the time on
all filesystems automatically (assuming the system clock has
been set properly and time(NULL) returns the proper time!).

Adds Dir::fileTime() to get the time of a file being listed, similar to
Dir::fileName() and Dir::fileSize().

Adds ::setTimeCallback(time_t (*cb)()) to File, Dir, and FS, allowing
users to override the default timestamp on a per-file, directory, or
filesystem basis. By default, a simple callback returning time(nullptr)
is implemented.

LittleFS uses the 't' attribute and should be backwards compatible.

SD/SDFS work and include wrappers for obsolete SdFat timestamp callbacks
using the MSDOS time.

This PR does not update SPIFFS, due to compatability concerns and a
possible massive rewrite which would make it possible to determine if an
old-style ot metadata enabled FS is present at mount time.

Includes an updated SD/listfiles and LittleFS_time example.

Replaces #6315

* Add links to new mklittlefs w/timestamp support

Include the update mklittlefs which generated 't' metadata on imported
files.
	../tools/sdk/lwip2/include/netif/lowpan6_opts.h

* Add explicit note about timestamp being local time

* Address review concerns

Clean up some awkward object instantiations.

Remove the _enableTime flag/setter from SPIFFS.

Clean up the FSConfig constructors using C++ style init lists.
@d-a-v
Copy link
Collaborator

d-a-v commented Nov 5, 2019

From what I can see, time.h should be included in this directory (copy-paste from your cmdline):

-I~/.platformio/packages/framework-arduinoespressif8266@src-31d658a59f41540201fc3726a1394910/tools/sdk/libc/xtensa-lx106-elf/include

I think this is an issue with the character ~ which is not properly expanded to your home directory.
Can you change all occurrences of ~ with /home/you in your graphical/file configuration ?

@Niek
Copy link
Contributor Author

Niek commented Nov 8, 2019

Found the issue: Time.h from Arduino Time Library conflicts on case-insensitive filesystems. See also:
#2341
PaulStoffregen/Time#74
me-no-dev/ESPAsyncWebServer#60

Closing this issue as it's a problem with the library.

@Niek Niek closed this as completed Nov 8, 2019
@d-a-v
Copy link
Collaborator

d-a-v commented Nov 8, 2019

Thanks for the links.
Instead of removing the offending Time.h, can you check if you can replace our #include <time.h> by #include <../include/time.h> and see if it works ?

@Niek
Copy link
Contributor Author

Niek commented Nov 8, 2019

@d-a-v good one, that works as well. So adding #include <../include/time.h> at the top of FS.h fixes the issue too.

@d-a-v
Copy link
Collaborator

d-a-v commented Nov 8, 2019

Are you willing to make a PR with this ?

edit
There are a number of files:

cores/esp8266/HardwareSerial.h
cores/esp8266/libc_replacements.cpp
cores/esp8266/time.cpp
libraries/ESP8266WiFi/examples/BearSSL_CertStore/BearSSL_CertStore.ino
libraries/ESP8266WiFi/examples/BearSSL_Server/BearSSL_Server.ino
libraries/ESP8266WiFi/examples/BearSSL_ServerClientCert/BearSSL_ServerClientCert.ino
libraries/ESP8266WiFi/examples/BearSSL_Sessions/BearSSL_Sessions.ino
libraries/ESP8266WiFi/examples/BearSSL_Validation/BearSSL_Validation.ino
libraries/ESP8266WiFi/examples/HTTPSRequestCACertAxTLS/HTTPSRequestCACertAxTLS.ino
libraries/ESP8266httpUpdate/examples/httpUpdateSecure/httpUpdateSecure.ino
libraries/ESP8266mDNS/examples/LEAmDNS/mDNS_Clock/mDNS_Clock.ino
libraries/esp8266/examples/NTP-TZ-DST/NTP-TZ-DST.ino
libraries/LittleFS/examples/LittleFS_Timestamp/LittleFS_Timestamp.ino

@devyte
Copy link
Collaborator

devyte commented Nov 8, 2019

I don't understand the core issue here, or how the suggested fix addresses it.

@Niek
Copy link
Contributor Author

Niek commented Nov 8, 2019

Are you willing to make a PR with this ?

edit
There are a number of files:

cores/esp8266/HardwareSerial.h
cores/esp8266/libc_replacements.cpp
cores/esp8266/time.cpp
libraries/ESP8266WiFi/examples/BearSSL_CertStore/BearSSL_CertStore.ino
libraries/ESP8266WiFi/examples/BearSSL_Server/BearSSL_Server.ino
libraries/ESP8266WiFi/examples/BearSSL_ServerClientCert/BearSSL_ServerClientCert.ino
libraries/ESP8266WiFi/examples/BearSSL_Sessions/BearSSL_Sessions.ino
libraries/ESP8266WiFi/examples/BearSSL_Validation/BearSSL_Validation.ino
libraries/ESP8266WiFi/examples/HTTPSRequestCACertAxTLS/HTTPSRequestCACertAxTLS.ino
libraries/ESP8266httpUpdate/examples/httpUpdateSecure/httpUpdateSecure.ino
libraries/ESP8266mDNS/examples/LEAmDNS/mDNS_Clock/mDNS_Clock.ino
libraries/esp8266/examples/NTP-TZ-DST/NTP-TZ-DST.ino
libraries/LittleFS/examples/LittleFS_Timestamp/LittleFS_Timestamp.ino

I made one for FS.h only: #6730
You want to change all time.h includes?

@Niek
Copy link
Contributor Author

Niek commented Nov 8, 2019

I don't understand the core issue here, or how the suggested fix addresses it.

Arduino Time Library (a popular library that offers some time-related functions) ships a header file called Time.h (capital T). When using this library, the issue occurs because on at least macOS and Windows the Time.h of the library is included instead of the correct time.h. Using the relative path forces the compiler to include the correct time.h.

@d-a-v
Copy link
Collaborator

d-a-v commented Nov 8, 2019

@devyte

That comment from @me-no-dev
me-no-dev/ESPAsyncWebServer#60 (comment)

but since it's too late to change that, we are in a sticky situation now and from now on...

and this one from @PaulStoffregen
PaulStoffregen/Time#74 (comment)

This library aims to preserve compatibility with older versions of Arduino.

@d-a-v
Copy link
Collaborator

d-a-v commented Nov 8, 2019

@Niek thanks for the PR.
This workaround may benefit to others, from links you referenced above.

@NitrofMtl
Copy link

Using the relative path forces the compiler to include the correct time.h

I install the library via the lib manager, so it is on \libdeps. I did not manage to get it work, what would be the path ?

#include <../libdeps/uno/Time/Time.h>

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

No branches or pull requests

4 participants