Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • Holy Smoke! Who would have known... Is this still true for latest ArduinoIDE compilers? I just tried it on an ESP32 and it causes repeated GuruMeditation errors. Commented Jul 4, 2019 at 16:44
  • @not2qubit I just tested on Arduino 1.8.9 and it is true there. Commented Jul 4, 2019 at 21:38
  • The warnings are there for a reason. This time I got: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] char bar = "This is some text"; - FORBIDS is a strong word. Since you are forbidden to do that, the compiler is free to muck around and share the same string over two variables. Don't do forbidden things! (Also, read and eliminate the warnings). :) Commented Jul 4, 2019 at 21:39
  • So in case you come across crappy code like this, and want to survive the day. Would an initial declaration of *foo and *bar using different string "constants", prevent this from happening? Also, how is this different from not putting any strings at all, like: char *foo;? Commented Jul 5, 2019 at 8:41
  • 1
    Different constants might help, but personally I wouldn't put anything there, and put data there in the usual way later (eg. with new, strcpy and delete). Commented Jul 5, 2019 at 21:49