Skip to content

Compilation Issue: flush() Marked override but does not override for NRF52 #38

@bhatasaka

Description

@bhatasaka

Operating System

Windows 11

IDE version

PlatiformIO Core:6.1.18, Home: 3.4.4, Arduino

Board

nrf52840_dk

BSP version

platformio/nordicnrf52 10.9.0

SPIFlash Library version

n/a

Sketch

examples/QuickStart.ino

What happened ?

When trying to compile this example, the following compilation error shows up:

In file included from .pio\libdeps\nrf52840_dk\SdFat - Adafruit Fork\src/ExFatLib/ExFatFile.h:882:0,
                 from .pio\libdeps\nrf52840_dk\SdFat - Adafruit Fork\src/ExFatLib/ExFatVolume.h:27,
                 from .pio\libdeps\nrf52840_dk\SdFat - Adafruit Fork\src/ExFatLib/ExFatLib.h:28,
                 from .pio\libdeps\nrf52840_dk\SdFat - Adafruit Fork\src/SdFat.h:30,
                 from src\main.cpp:5:
.pio\libdeps\nrf52840_dk\SdFat - Adafruit Fork\src/ExFatLib/../common/ArduinoFiles.h: In instantiation of 'class PrintFile<FatFile>':
.pio\libdeps\nrf52840_dk\SdFat - Adafruit Fork\src/SdFat.h:468:23:   required from here
.pio\libdeps\nrf52840_dk\SdFat - Adafruit Fork\src/ExFatLib/../common/ArduinoFiles.h:52:8: error: 'void PrintFile<BaseFile>::flush() [with BaseFile = FatFile]' marked 'override', but does not override
   void flush() override { BaseFile::sync(); }
        ^~~~~

It looks like the class PrintFile in src/common/ArduinoFiles.h implements void flush() override { BaseFile::sync(); } where BaseFile is FatFile. But neither of the inherited classes (Arduino Print implemented in the Arduino Nordic NRF5 core) or FatFile implement void flush() as virtual, meaning it cannot be overridden. There are preprocessor flags to select a version of the function declaration that doesn't ask to override, but it isn't selected since this isn't an Arduino Due board.

ArduinoFiles.h lines 48-53:

  /** Ensure that any bytes written to the file are saved to the SD card. */
#if defined(ARDUINO_SAM_DUE) && !defined(ARDUINO_API_VERSION)
  void flush() { BaseFile::sync(); }
#else
  void flush() override { BaseFile::sync(); }
#endif

This does not happen with version 2.2.54, but happens with any version after - 2.3 and up.

How to reproduce ?

  1. Create new platformio project for the nRF52840 DK
  2. Add the Adafruit SDFat library to the dependencies so the platformio.ini file looks like this:
[env:nrf52840_dk]
platform = nordicnrf52
board = nrf52840_dk
framework = arduino
lib_deps =  adafruit/SdFat - Adafruit Fork@^2.3
  1. Copy in the examples/QuickStart.ino to main.cpp
  2. Build and see compilation output

Debug Log

No response

Screenshots

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions