Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Compile errors on EEPROM.h - 'String' does not name a type (T3.2)

  1. #1
    Member
    Join Date
    Oct 2012
    Location
    Austin TX
    Posts
    20

    Compile errors on EEPROM.h - 'String' does not name a type (T3.2)

    I have a project that has been working just fine and today a github continuous integration started throwing an error with regards to PlatformIO compiling.

    Seems there's been some update to the teensy libraries? My previous install was working fine, but after updating teensy libraries I see the compile error on my setup as well (PIO in vscode). Errors below

    This seems related to changes to EEPROM.h on April 8, 2022 (?)

    I see the same issue when compiling with a brand new install of Teensyduino 1.57

    Stackoverflow shows some solutions for this type of error by including
    Code:
    #include <string> 
    using namespace std;
    But - shouldn't that be part of the EEPROM library?

    What am I doing wrong?

    Code:
    In file included from OMX-27-firmware/storage.cpp:1:0:
    /Users/nevetsokyeron/.platformio/packages/framework-arduinoteensy/libraries/EEPROM/EEPROM.h:171:14: error: 'String' does not name a type
     inline const String &EEPROMClass::put(int idx, const String &s)
                  ^
    /Users/nevetsokyeron/.platformio/packages/framework-arduinoteensy/libraries/EEPROM/EEPROM.h:191:8: error: 'String' does not name a type
     inline String &EEPROMClass::get(int idx, String &s){
            ^

  2. #2
    Member
    Join Date
    Oct 2012
    Location
    Austin TX
    Posts
    20
    replying to myself here...

    adding this before my EEPROM.h include seems to solve the compile error (In Teensyduino anyway), but I'd like to know why this is now needed when it was not before

    #include <WString.h>

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,814
    Some libraries depend on include Arduino.h, which Arduino IDE automatically adds, but PlatformIO does not.

    Quote Originally Posted by nevetsokyeron View Post
    but I'd like to know why this is now needed when it was not before
    EEPROM get() and put() were improved to work properly with String variables, thanks to a contribution from Luni64. With Teensyduino 1.56 and earlier, attempting to use any String variable did not work properly. Even if you don't personally use String or see the value in supporting it, people who do use String ran into this limitation. Code was added in EEPROM.h to make that case work automatically. But it seems nobody using PlatformIO ever tests the beta versions, so even though we had 4 beta versions published before releasing 1.57, it seems all testing was done only with Arduino IDE 1.8.x and 2.0-rc.x.

  4. #4
    Member
    Join Date
    Oct 2012
    Location
    Austin TX
    Posts
    20
    Thanks for the info on the changes to EEPROM.h

    Quote Originally Posted by PaulStoffregen View Post
    Some libraries depend on include Arduino.h, which Arduino IDE automatically adds, but PlatformIO does not.
    To be clear - arduino.h is/was included in this project already (unless it needs to be re-included for some reason).

    including WString.h fixed the compile errors. Is that the correct solution?

  5. #5
    Senior Member
    Join Date
    Aug 2018
    Location
    Brisbane, Australia
    Posts
    129

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •