Skip to main content
1 of 3
Nick Gammon
  • 38.9k
  • 13
  • 70
  • 126

Example:

void foo (char * s)
  {
  Serial.println (s);
  }
  
void setup ()
  {
  Serial.begin (115200);
  Serial.println ();
  foo ("bar");
  }  // end of setup

void loop ()
  {
  }  // end of loop

Warning:

sketch_jul14b.ino: In function ‘void setup()’:
sketch_jul14b.ino:10: warning: deprecated conversion from string constant to ‘char*’

The function foo expects a char* (which it can therefore modify) but you are passing a string literal, which should not be modified.

The compiler is warning you not to do this. Being deprecated it might turn from a warning into an error in a future compiler version.


Solution: Make foo take a const char *:

void foo (const char * s)
  {
  Serial.println (s);
  }
Nick Gammon
  • 38.9k
  • 13
  • 70
  • 126