ESP32 Time Error

最近在编译一个 ESP32 Arduino代码的时候碰到了如下很奇怪的问题:

In file included from c:\users\DaveX\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\bits\locale_facets_nonio.h:39,
                 from c:\users\DaveX\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\locale:41,
                 from c:\users\DaveX\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\iomanip:43,
                 from C:\Users\DaveX\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.4\libraries\BluetoothSerial\src\BTAddress.cpp:15:
c:\users\DaveX\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\ctime:64:11: error: '::clock' has not been declared
   using ::clock;
           ^~~~~
c:\users\DaveX\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\ctime:65:11: error: '::difftime' has not been declared
   using ::difftime;
           ^~~~~~~~
c:\users\DaveX\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\ctime:66:11: error: '::mktime' has not been declared
   using ::mktime;
           ^~~~~~
c:\users\DaveX\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\ctime:67:11: error: '::time' has not been declared
   using ::time;
           ^~~~
c:\users\DaveX\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\ctime:68:11: error: '::asctime' has not been declared
   using ::asctime;
           ^~~~~~~
c:\users\DaveX\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\ctime:69:11: error: '::ctime' has not been declared
   using ::ctime;
           ^~~~~
c:\users\DaveX\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\ctime:70:11: error: '::gmtime' has not been declared
   using ::gmtime;
           ^~~~~~
c:\users\DaveX\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\ctime:71:11: error: '::localtime' has not been declared
   using ::localtime;
           ^~~~~~~~~
c:\users\DaveX\appdata\local\arduino15\packages\esp32\tools\xtensa-esp32-elf-gcc\gcc8_4_0-esp-2021r2-patch3\xtensa-esp32-elf\include\c++\8.4.0\ctime:72:11: error: '::strftime' has not been declared
   using ::strftime;
           ^~~~~~~~

经过搜索,有人碰到了类似的问题,产生问题的原因是:使用的代码中有 time.h 这个名称的文件。我的代码中没有,但是使用到的 DFRobot_OLED12864 这个库里面有。解决方法很简单:把这个库中的time.h 改个名称即可。

希望能帮助到碰到同样问题的朋友。

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注