Compile Error: SdFat_Usage.ino - Starting with TD1.57B1 up to TD1.57B3

wwatson

Well-known member
Was testing SdFat_Usage to see how to use the SdFat bytesPerSector() function and received this compile error:

Code:
SdFat_Usage: In function 'void setup()':
SdFat_Usage:122: error: call of overloaded 'write(char)' is ambiguous
   myfile.write('\0'); // add a null byte to mark end of string
                    ^
In file included from /home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SdFat/src/ExFatLib/ExFatFile.h:821:0,
                 from /home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SdFat/src/ExFatLib/ExFatVolume.h:27,
                 from /home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SdFat/src/ExFatLib/ExFatLib.h:27,
                 from /home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SdFat/src/SdFat.h:35,
                 from /home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SD/src/SD.h:27,
                 from /home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SD/examples/SdFat_Usage/SdFat_Usage.ino:18:
/home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SdFat/src/ExFatLib/../common/ArduinoFiles.h:140:10: note: candidate: size_t StreamFile<BaseFile, PosType>::write(uint8_t) [with BaseFile = FsBaseFile; PosType = long long unsigned int; size_t = unsigned int; uint8_t = unsigned char]
   size_t write(uint8_t b) {
          ^
In file included from /home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SdFat/src/FsLib/FsLib.h:32:0,
                 from /home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SdFat/src/SdFat.h:37,
                 from /home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SD/src/SD.h:27,
                 from /home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SD/examples/SdFat_Usage/SdFat_Usage.ino:18:
/home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SdFat/src/FsLib/FsFile.h:761:10: note: candidate: size_t FsBaseFile::write(const char*)
   size_t write(const char* str) {
          ^
Multiple libraries were found for "SD.h"
 Used: /home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SD
 Not used: /home/wwatson/arduino-1.8.19.org2/libraries/SD
Using library SD at version 2.0.0 in folder: /home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SD 
Using library SdFat at version 2.1.2 in folder: /home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SdFat 
Using library SPI at version 1.0 in folder: /home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SPI 
call of overloaded 'write(char)' is ambiguous

Went back to TD1.56 release and the sketch compiled without error.
Tested with clean install of Arduino 1.8.19 and TD1.57B1 to 1.57B3 Ubuntu 20.04.

Has anybody else run into this?
 
With the SDFat stuff, I know Paul has pulled in more recent version of Bill's stuff. He also removed some of the stuff we had added as to limit how many changes are needed for our stuff to work.

We have pulled in some of the stuff into other places, like the format code into USBHost...

Plus we had to replicate a function or two like that...

So yes the SD example does not built... Will take a look
 
Although the fix to build was to change line 122 in the example
From:
Code:
  myfile.write('\0'); // add a null byte to mark end of string
To:
Code:
 myfile.write((uint8_t)'\0'); // add a null byte to mark end of string
Not sure yet why the cast is needed now and not before... Wonder what changed in SDFat...
 
Although the fix to build was to change line 122 in the example
From:
Code:
  myfile.write('\0'); // add a null byte to mark end of string
To:
Code:
 myfile.write((uint8_t)'\0'); // add a null byte to mark end of string
Not sure yet why the cast is needed now and not before... Wonder what changed in SDFat...

Your right the cast allows it to compile clean...

It will also compile and work with this:
Code:
  myfile.write(""); // add a null byte to mark end of string

Or:
Code:
  myfile.print("Just some test data written to the file (by SdFat functions)\0");

Possibly a conflict between:
Code:
/home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SdFat/src/ExFatLib/../common/ArduinoFiles.h:140:10: note: candidate: size_t StreamFile<BaseFile, PosType>::write(uint8_t) [with BaseFile = FsBaseFile; PosType = long long unsigned int; size_t = unsigned int; uint8_t = unsigned char]
   size_t write(uint8_t b) {
and:
Code:
/home/wwatson/arduino-1.8.19.org2/hardware/teensy/avr/libraries/SdFat/src/FsLib/FsFile.h:761:10: note: candidate: size_t FsBaseFile::write(const char*)
   size_t write(const char* str) {

:confused:
 
Back
Top