Warning message for TMRpcm.cpp:?

Hi all experts, I am fairly new to Arduino, am doing this for a new hobby, I used a code from the internet and i received warning messages, how do i solve this issues? It is in my TMRPCM.CPP, (CPP FILE)?

This is the warning message that shows up

C:\Users\PbP\Documents\Arduino\libraries\TMRpcm\TMRpcm.cpp: In member function 'byte TMRpcm::metaInfo(boolean, char*, char*, byte)':

C:\Users\PbP\Documents\Arduino\libraries\TMRpcm\TMRpcm.cpp:1382:18: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

   char* datStr = "LIST";

                  ^~~~~~

C:\Users\PbP\Documents\Arduino\libraries\TMRpcm\TMRpcm.cpp:1383:30: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

   if(infoType == 1){datStr = "ID3 "; datStr[3] = 3;}

                              ^~~~~~

C:\Users\PbP\Documents\Arduino\libraries\TMRpcm\TMRpcm.cpp:1411:42: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

  char* tagNames[] = {"INAM","IART","IPRD"};

                                          ^

C:\Users\PbP\Documents\Arduino\libraries\TMRpcm\TMRpcm.cpp:1411:42: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\PbP\Documents\Arduino\libraries\TMRpcm\TMRpcm.cpp:1411:42: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

C:\Users\PbP\Documents\Arduino\libraries\TMRpcm\TMRpcm.cpp:1431:18: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

    tagNames[0] = "TPE1"; tagNames[1] ="TIT2"; tagNames[2] ="TALB";

                  ^~~~~~

C:\Users\PbP\Documents\Arduino\libraries\TMRpcm\TMRpcm.cpp:1431:39: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

    tagNames[0] = "TPE1"; tagNames[1] ="TIT2"; tagNames[2] ="TALB";

                                       ^~~~~~

C:\Users\PbP\Documents\Arduino\libraries\TMRpcm\TMRpcm.cpp:1431:60: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

    tagNames[0] = "TPE1"; tagNames[1] ="TIT2"; tagNames[2] ="TALB";

                                                            ^~~~~~

C:\Users\PbP\Documents\Arduino\libraries\TMRpcm\TMRpcm.cpp: In member function 'void TMRpcm::finalizeWavTemplate(char*)':

C:\Users\PbP\Documents\Arduino\libraries\TMRpcm\TMRpcm.cpp:1569:65: warning: narrowing conversion of '(fSize >> 16)' from 'long unsigned int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]

  seek(4); byte data[4] = {lowByte(fSize),highByte(fSize), fSize >> 16,fSize >> 24};

                                                           ~~~~~~^~~~~

C:\Users\PbP\Documents\Arduino\libraries\TMRpcm\TMRpcm.cpp:1569:77: warning: narrowing conversion of '(fSize >> 24)' from 'long unsigned int' to 'byte {aka unsigned char}' inside { } [-Wnarrowing]

  seek(4); byte data[4] = {lowByte(fSize),highByte(fSize), fSize >> 16,fSize >> 24};
char* datStr = "LIST";

datStr is not declared const whereas "LIST", by its very nature is const

If you declare datStr as const then that particular warning will not be issued

Ty

It's a common hold-over from ancient times before the 'const' keyword was available. All pointers could be used to both read and write. When the 'const' keyword became available it became possible to declare a pointer as 'read only' by saying that it pointed to 'const' values. Then that attribute was applied to string constants like "LIST".

The best fix is to declare the destination string pointer as read-only: const char *

If the destination pointer is an argument to a library function you would have to modify the library to fix it. If you don't want to modify the library you can cast your string constant to "char *" to allow it to be passed to the library function without warning:

   libraryFunction((char *)"LIST");