witnessmenow / spotify-api-arduino

Arduino library for integrating with the Spotify Web-API (Does not play music)
MIT License
182 stars 32 forks source link

Warnings on Arduino IDE #7

Closed krulkip closed 4 years ago

krulkip commented 4 years ago

I am getting many warnings on arduino IDE. warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] The small program below shows where these come from. You can find one for instance on line 104 of the ArduinoSpotify.h file. ArduinoSpotify(Client &client, char clientId, char clientSecret, char refreshToken = ""); char refreshToken = "" this part gives the warning as illustrated below You can remove the warning by adding (char ) as shown below but not sure program then still works as intended

char refreshToken1 [] = ""; //Is Ok char refreshToken2 = (char )""; //Is OK char *refreshToken3 = ""; // gives above warning void setup() { } void loop() { }

witnessmenow commented 4 years ago

Updated, I no longer have any compiler warnings.

krulkip commented 4 years ago

Thank you very much for fixing that. I still get one warning. getRefreshToken.ino: In function 'void handleCallback()': getRefreshToken:118: error: invalid conversion from 'const char' to 'char' [-fpermissive] refreshToken = spotify.requestAccessTokens((char*)code.c_str(), callbackURI);

                                             ^
witnessmenow commented 4 years ago

Ok thanks I'll fix that when I'm working on it again. For now I think you could just remove the cast to (char *) before code.c_str

On Fri 31 Jul 2020, 07:35 krulkip, notifications@github.com wrote:

Thank you very much for fixing that. I still get one warning. getRefreshToken.ino: In function 'void handleCallback()': getRefreshToken:118: error: invalid conversion from 'const char' to 'char' [-fpermissive] refreshToken = spotify.requestAccessTokens((char*)code.c_str(), callbackURI);

                                         ^

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/witnessmenow/arduino-spotify-api/issues/7#issuecomment-666956034, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAL5PQVGEAY4J4ULPXXVUZLR6JQ27ANCNFSM4PM6YVZA .

krulkip commented 4 years ago

I forked your library and made the changes to fix this issue. Not tested it yet but it assembles without errors.

krulkip commented 4 years ago

All working OK now. Tested both getrefreshtoken and getcurrentlyplaying. Thank you so much. Super cool.