Skip to content

compile error unter platform.io with Arduino framework #39

Description

@ST-Oldie

I add this library to a project under platform.io with Arduino framework and got a error while compiling this lib:

In file included from /home/michael/.platformio/packages/framework-arduinoespressif8266/libraries/SD/src/SD.h:24,
                 from .pio/libdeps/esp12e/IniFile/src/IniFile.h:10,
                 from .pio/libdeps/esp12e/IniFile/src/IniFile.cpp:1:
/home/michael/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/FS.h:70:23: note:   initializing argument 1 of 'virtual int fs::File::read(uint8_t*, size_t)'
   70 |     int read(uint8_t* buf, size_t size) override;

I think, the problem can be fixed by change fs::File::read() to fs::File::readBytes() which has a "char *" as first parameter and calls read() with a typecast to "unit8:t *"
A typecast should also work.

Activity

  1. ST-Oldie commented on Mar 30, 2025

    @ST-Oldie
    Author

    I have additional informations. I took a look in the code and found condition compilation.

    #if defined(ARDUINO_ARCH_ESP32) && !defined(PREFER_SDFAT_LIBRARY)
    	size_t bytesRead = file.readBytes(buffer, len);
    #else
    	size_t bytesRead = file.read(buffer, len);
    #endif
    
    

    The platform i used is a esp8266. So the define for the architecture is different. I suggest to change this part to:

    #if (defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)) && !defined(PREFER_SDFAT_LIBRARY)
    	size_t bytesRead = file.readBytes(buffer, len);
    #else
    	size_t bytesRead = file.read(buffer, len);
    #endif
    
    

    This solves the problem for me.
    Than you for you work and best regards
    Michael Bernstein

  2. ST-Oldie commented on Apr 3, 2025

    @ST-Oldie
    Author

    One additional question:
    Is the check for the architectuer really needed? I got the feeling, fs:File::read has on all platforms a uint8_t * as first parameter. So i thought, using readBytes should be used on all architectures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions