Lots of warning: ISO C++ forbids converting a string constant to 'char*'

Hi together,

I got loads of warnings when I even compile standard examples like the GSM "Receive SMS" (see below).

Ok, I understand the warnings, but I didn't expect these warning in standard examples...

Cheers
Max

-------------- 8< ---------------

In file included from /Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM.h:46:0,
from /Applications/Arduino.app/Contents/Java/libraries/GSM/examples/ReceiveSMS/ReceiveSMS.ino:21:
/Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM3ShieldV1BandManagement.h:49:1: warning: 'typedef' was ignored in this declaration
typedef enum GSM3GSMBand {UNDEFINED, EGSM_MODE, DCS_MODE, PCS_MODE, EGSM_DCS_MODE, GSM850_PCS_MODE, GSM850_EGSM_DCS_PCS_MODE};
^~~~~~~
/Applications/Arduino.app/Contents/Java/libraries/GSM/examples/ReceiveSMS/ReceiveSMS.ino: In function 'void setup()':
/Applications/Arduino.app/Contents/Java/libraries/GSM/examples/ReceiveSMS/ReceiveSMS.ino:47:34: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
^
/Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM3MobileMockupProvider.cpp: In constructor 'GSM3MobileMockupProvider::GSM3MobileMockupProvider()':
/Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM3MobileMockupProvider.cpp:44:13: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
msgExample="Hello#World";
^~~~~~~~~~~~~
/Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM3MobileMockupProvider.cpp: In member function 'int GSM3MobileMockupProvider::connectTCPServer(int, char*, int*)':
/Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM3MobileMockupProvider.cpp:183:32: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
strcpy("192.168.1.1", localIP);
^
In file included from /Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM3ShieldV1BandManagement.cpp:34:0:
/Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM3ShieldV1BandManagement.h:49:1: warning: 'typedef' was ignored in this declaration
typedef enum GSM3GSMBand {UNDEFINED, EGSM_MODE, DCS_MODE, PCS_MODE, EGSM_DCS_MODE, GSM850_PCS_MODE, GSM850_EGSM_DCS_PCS_MODE};
^~~~~~~
/Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM3ShieldV1BandManagement.cpp: In constructor 'GSM3ShieldV1BandManagement::GSM3ShieldV1BandManagement(bool)':
/Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM3ShieldV1BandManagement.cpp:38:28: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
quectelStrings[UNDEFINED]="";
^~
/Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM3ShieldV1BandManagement.cpp:39:28: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
quectelStrings[EGSM_MODE]=""EGSM_MODE"";
^~~~~~~~~~~~~~~
/Applications/Arduino.app/Contents/Java/libraries/GSM/src/GSM3ShieldV1BandManagement.cpp:40:27: warning: ISO C++ forbids converting a string constant to 'char*'

@octeon

Your topic was Moved to it's current location / section as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Since the 'const' keyword was not added to C until the 1989 standard, many older programmers, and people who learn from them, do not use the 'const' keyword as much as they should, particularly in function arguments. The const keyword on a pointer argument means "I promise not to use this pointer to change the data it points to." The "warning: ISO C++ forbids converting a string constant to 'char*'" usually means that you are saving the address of a "const chart *" (string constant) into a "char *" or passing a "const char *" (string constant) to a function that declares the argument "char *".

I think I know what's wrong, but without seeing the whole sketch, I would just be guessing.

" but I didn't expect these warning in standard examples..."
The default IDE setting is to not show warnings. I suspect that the person who wrote the example sketch is not looking for warnings.

This is actually more common than it should be, but I think the IDE developers didn't want to intimidate new users with tons of warnings that the compiler was able to "fix". My recommendation is that anyone with some Arduino experience turn on "show warnings" in the IDE preferences. Correcting warnings will make you a better programmer and also save you hours of grief if an update to the compiler changes a warning to an error.

The interesting thing ist, that although the show-warning-setting is set to "none" (V 1.8.13) the IDE is showing warnings...

If I recall correctly, this particular warning has only started showing up in the more recent versions of the IDE, maybe the last year or so. Probably some change in the command used when invoking the compiler. The ESP8266 core will flag this as an error instead of a warning I believe.