Adafruit_SPIFlash.h & Adafruit_ImageReader won't compile on Arduino Nano 33 BLE

Hi,

I would really like to use my new Adafruit 0.96" OLED display with my brand new Arduino Nano 33 BLE board. I had no trouble connecting the Display to a normal Arduino Nano and the Adafruit ItsyBitsy M0, but it fails to compile on the new Arduino Nano 33 BLE. I know that the Nano 33 BLE uses a different chipset, and guess that's causing the problem.

One of the required includes for the OLED display is: #include <Adafruit_ImageReader.h>

If I try to compile with a basically blank sketch and just the include, it throws a long list of errors:

In file included from /Users/chris/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_default_fcntl.h:200:0,
                 from /Users/chris/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/fcntl.h:4,
                 from /Users/chris/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/fcntl.h:1,
                 from /Users/chris/Documents/Arduino/libraries/SdFat-master/src/FatLib/FatApiConstants.h:30,
                 from /Users/chris/Documents/Arduino/libraries/SdFat-master/src/FatLib/FatFile.h:36,
                 from /Users/chris/Documents/Arduino/libraries/SdFat-master/src/FatLib/ArduinoFiles.h:33,
                 from /Users/chris/Documents/Arduino/libraries/SdFat-master/src/FatLib/FatLib.h:27,
                 from /Users/chris/Documents/Arduino/libraries/SdFat-master/src/SdFat.h:33,
                 from /Users/chris/Documents/Arduino/libraries/Adafruit_SPIFlash/src/Adafruit_SPIFlash.h:35,
                 from /Users/chris/Documents/Arduino/libraries/Adafruit_ImageReader_Library/Adafruit_ImageReader.h:19,
                 from /Users/chris/Documents/Arduino/Test/Test.ino:4:
/Users/chris/Library/Arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/stat.h:27:8: error: redefinition of 'struct stat'
 struct stat
        ^~~~
In file included from /Users/chris/Library/Arduino15/packages/arduino/hardware/mbed/1.1.2/cores/arduino/mbed/platform/mbed_error.h:28:0,
                 from /Users/chris/Library/Arduino15/packages/arduino/hardware/mbed/1.1.2/cores/arduino/mbed/rtos/Queue.h:28,
                 from /Users/chris/Library/Arduino15/packages/arduino/hardware/mbed/1.1.2/cores/arduino/mbed/rtos/Mail.h:28,
                 from /Users/chris/Library/Arduino15/packages/arduino/hardware/mbed/1.1.2/cores/arduino/mbed/rtos/rtos.h:33,
                 from /Users/chris/Library/Arduino15/packages/arduino/hardware/mbed/1.1.2/cores/arduino/mbed/mbed.h:23,
                 from /Users/chris/Library/Arduino15/packages/arduino/hardware/mbed/1.1.2/cores/arduino/Arduino.h:32,
                 from sketch/Test.ino.cpp:1:
/Users/chris/Library/Arduino15/packages/arduino/hardware/mbed/1.1.2/cores/arduino/mbed/platform/mbed_retarget.h:500:8: note: previous definition of 'struct stat'
 struct stat {
        ^~~~

And after that there are lots of warnings about multiple libraries being found:

Multiple libraries were found for "Adafruit_ImageReader.h"
 Used: /Users/chris/Documents/Arduino/libraries/Adafruit_ImageReader_Library
Multiple libraries were found for "Adafruit_SPITFT.h"
 Used: /Users/chris/Documents/Arduino/libraries/Adafruit_GFX_Library
Multiple libraries were found for "SPI.h"
 Used: /Users/chris/Library/Arduino15/packages/arduino/hardware/mbed/1.1.2/libraries/SPI
Multiple libraries were found for "Adafruit_SPIFlash.h"
 Used: /Users/chris/Documents/Arduino/libraries/Adafruit_SPIFlash
Multiple libraries were found for "SdFat.h"
 Used: /Users/chris/Documents/Arduino/libraries/SdFat-master
exit status 1
Error compiling for board Arduino Nano 33 BLE.

The exact same errors are thrown if I compile with: #include <Adafruit_SPIFlash.h>

Is there some way to fix this? I am not sure where the error lies... with the Adafruit libraries or the Nano 33 BLE core libraries (which admittedly are much newer and untested). I feel like an #IFDEF (or equivalent) around the re-declared "struct stat" could solve it, but this is outside my wheelhouse.

Thank you.

I did try to repport it on adafruit / Adafruit_ImageReader

The answer is that it's part of the Arduino core and their can't do much about it...

Between two stools, one falls to the ground

As I said in the github issue, it looks to me like the issue is that the library is naming a struct the same thing ('stat') that the core library uses for a different purpose...

If my analysis is correct, that is indeed an issue with the library - a third party library should not use a name that conflicts with the core libraries. And fixing it would just be a find/replace job...