greiman / SdFat

Arduino FAT16/FAT32 exFAT Library
MIT License
1.08k stars 509 forks source link

Redefinition of struct stat #204

Open victorromeo opened 4 years ago

victorromeo commented 4 years ago

SdFat Version 1.1.4 Arduino IDE - 1.8.12 Board - Arduino Nano 33 BLE Sense

When compiling the out-of-the-box RawWrite example I'm getting a compilation error, caused by colliding definitions error: redefinition of 'struct stat'.

May I get some advice how to proceed?

In file included from /home/ian/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/_default_fcntl.h:200:0,
                 from /home/ian/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/fcntl.h:4,
                 from /home/ian/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/fcntl.h:1,
                 from /home/ian/Arduino/libraries/SdFat/src/FatLib/FatApiConstants.h:30,
                 from /home/ian/Arduino/libraries/SdFat/src/FatLib/FatFile.h:36,
                 from /home/ian/Arduino/libraries/SdFat/src/FatLib/ArduinoFiles.h:33,
                 from /home/ian/Arduino/libraries/SdFat/src/FatLib/FatLib.h:27,
                 from /home/ian/Arduino/libraries/SdFat/src/SdFat.h:33,
                 from /home/ian/Arduino/libraries/SdFat/examples/RawWrite/RawWrite.ino:14:
/home/ian/.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 /home/ian/.arduino15/packages/arduino/hardware/mbed/1.1.6/cores/arduino/mbed/platform/platform.h:26:0,
                 from /home/ian/.arduino15/packages/arduino/hardware/mbed/1.1.6/cores/arduino/mbed/drivers/InterruptIn.h:20,
                 from /home/ian/.arduino15/packages/arduino/hardware/mbed/1.1.6/cores/arduino/Arduino.h:35,
                 from sketch/RawWrite.ino.cpp:1:
/home/ian/.arduino15/packages/arduino/hardware/mbed/1.1.6/cores/arduino/mbed/platform/mbed_retarget.h:501:8: note: previous definition of 'struct stat'
 struct stat {
        ^~~~
exit status 1
Error compiling for board Arduino Nano 33 BLE.
greiman commented 4 years ago

I don't use the struct stat which is defined in the system file fcntl.h.

mbed_retarget.h has a definition that conflicts with the stat in fcntl.h

You can try editing SdFatConfig.h and set USE_FCNTL_H zero. This may cause other problems.

Arduino or mbed should do something to fix this.