JAndrassy/ArduinoOTA

Invalid conversion from 'const char*' to 'char*'

kongdayan opened this issue · 2 comments

I use platformio Vscode and this library to develop arudino nano 33 IOT, it works fine at the beginning, but when I update the library, I find that vscode prompts me to exist Invalid conversion problem.

lib\SD_CARD/SD_CARD.h: In function 'void SD_Lowpower()':
lib\SD_CARD/SD_CARD.h:135:26: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
   SD.remove("RUBBISH.txt");
                          ^
In file included from .pio\libdeps\nano_33_iot\ArduinoOTA\src/ArduinoOTA.h:37:0,
                 from src\main.cpp:22:
.pio\libdeps\nano_33_iot\ArduinoOTA\src/SDStorage.h: In member function 'virtual void SDStorageClass::clear()':
.pio\libdeps\nano_33_iot\ArduinoOTA\src/SDStorage.h:48:15: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
     SD.remove(updateFileName);
               ^~~~~~~~~~~~~~
In file included from lib\SD_CARD/SD_CARD.h:6:0,
                 from src\main.cpp:14:
.pio\libdeps\nano_33_iot\SD/SD.h:97:11: note:   initializing argument 1 of 'boolean SDClass::remove(char*)'
   boolean remove(char *filepath);
           ^~~~~~
src\main.cpp: In function 'void setup()':
Compiling .pio\build\nano_33_iot\lib141\ArduinoUniqueID\ArduinoUniqueID.cpp.o
src\main.cpp:234:30: warning: right operand of comma operator has no effect [-Wunused-value]
       UIDtemp=UniqueID[i],HEX;
                              ^
src\main.cpp: In function 'void loop()':
src\main.cpp:305:33: warning: right operand of comma operator has no effect [-Wunused-value]
   average = scale.get_units(3),4;//read weight, average for oled display
                                 ^
src\main.cpp:518:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
           SD.remove("WIFIPWD.txt");
                                  ^
src\main.cpp:519:35: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
           SD.remove("WIFISSID.txt");
Compiling .pio\build\nano_33_iot\libbf4\RTCZero\RTCZero.cpp.o
                                   ^
src\main.cpp:558:28: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
       SD.remove("CALIB.txt");
                            ^
src\main.cpp:566:28: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
       SD.remove("RESET.txt"); // delete reset.txt, so only last offset will be saved
                            ^
src\main.cpp:577:30: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
       SD.remove("RFIDPWR.txt");
                              ^
src\main.cpp: In function 'void weightscaleInit(float)':
src\main.cpp:730:26: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     SD.remove("RESET.txt"); // delete reset.txt, so only last offset will be saved
                          ^
src\main.cpp:742:26: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     SD.remove("CALIB.txt"); // delete reset.txt, so only last offset will be saved
                          ^
src\main.cpp: In function 'void wifiInit()':
src\main.cpp:887:28: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     SD.remove("WIFIPWD.txt");
                            ^
src\main.cpp:888:29: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     SD.remove("WIFISSID.txt");
                             ^
src\main.cpp: In function 'void rfidsdread()':
src\main.cpp:1146:28: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
Compiling .pio\build\nano_33_iot\lib25e\Arduino Low Power\nrf52\ArduinoLowPower.cpp.o
     SD.remove("RFIDPWR.txt");
                            ^
src\main.cpp: In function 'void wifiSleep()':
src\main.cpp:1208:28: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     SD.remove("WIFIPWD.txt");
                            ^
src\main.cpp:1209:29: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
     SD.remove("WIFISSID.txt");
                             ^
*** [.pio\build\nano_33_iot\src\main.cpp.o] Error 1
.pio\libdeps\nano_33_iot\SD\utility\SdFile.cpp: In member function 'uint8_t SdFile::rmRfStar()':
.pio\libdeps\nano_33_iot\SD\utility\SdFile.cpp:907:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (curPosition_ != (32*(index + 1))) {
         ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
.pio\libdeps\nano_33_iot\SD\utility\Sd2Card.cpp: In member function 'uint8_t Sd2Card::readData(uint32_t, uint16_t, uint16_t, uint8_t*)':
.pio\libdeps\nano_33_iot\SD\utility\Sd2Card.cpp:438:12: warning: unused variable 'n' [-Wunused-variable]
   uint16_t n;
            ^
.pio\libdeps\nano_33_iot\RTCZero\src\RTCZero.cpp: In member function 'void RTCZero::begin(bool)':
.pio\libdeps\nano_33_iot\RTCZero\src\RTCZero.cpp:96:26: warning: 'oldTime.RTC_MODE2_CLOCK_Type::reg' may be used uninitialized in this function [-Wmaybe-uninitialized]
     RTC->MODE2.CLOCK.reg = oldTime.reg;
============================================================ [FAILED] Took 7.20 seconds =

It seems a problem with "updateFileName" in https://github.com/JAndrassy/ArduinoOTA/blob/master/src/SDStorage.h
Vscode
I try to fix it by add (char *) and it works.
Fix

you have some very old version of the SD library

😊you are right, I review my lib_deps I found that my project are using this SD Library

SD . @ 0.0.0-alpha+sha.041f78825

after I find some to replace this one , it works.

arduino-libraries/SD