deprecated conversion from string constant to 'char*
Posted: Thu May 05, 2016 3:59 pm
I need to pass different strings to a function. When I do so I get the compiler warning: "deprecated conversion from string constant to 'char*'".
The sketch loads to the ESP8266 and works just fine. If I run the same sketch on the Arduino Uno, I don't even get the warning.
Here is a very simple code example that produces the warning (actually twice):
It seems the proper way to do this is as follows:
That's a lot more code. If I use the "proper method" I would have to create about 30 variables to handle all my function calls.
Is there any hidden danger of using the code that produces the compiler warnings?
Thanks and regards
The sketch loads to the ESP8266 and works just fine. If I run the same sketch on the Arduino Uno, I don't even get the warning.
Here is a very simple code example that produces the warning (actually twice):
Code: Select all
void functionToPassTo(char* someString){
//some code
}
void setup() {
functionToPassTo("Hello");
functionToPassTo("GoodBy");
}
It seems the proper way to do this is as follows:
Code: Select all
void functionToPassTo(char* someString){
//some code
}
void setup() {
char passToFunction_1[] = "Hello";
functionToPassTo(passToFunction_1);
char passToFunction_2[] = "GoodBy";
functionToPassTo(passToFunction_2);
}
That's a lot more code. If I use the "proper method" I would have to create about 30 variables to handle all my function calls.
Is there any hidden danger of using the code that produces the compiler warnings?
Thanks and regards