Incorrect documentation, build_flags -DTEXT_CONST="Some string of text"

This page documents build_flags options, specifically regarding to strings with embedded spaces.

However, none of the examples actually work.

What is the proper, current method for defining a constant expression for text?

build_flags = -DWIFI_PASS="My\ pass'word"

results in error
arm-none-eabi-g++.exe: error: pass’word": Invalid argument

‘-DWIFI_PASS=“My password”’
results in error
arm-none-eabi-g++.exe: error: password": Invalid argument

See How could the main.cpp read the parameters at platformio.ini? - #3 by maxgerhardt and Inject Board Name into Code - #2 by maxgerhardt for the correct string escaping technique.

For the documentation bug: I think I remember that that this is also OS-dependent and it works under Linux, but not universally. In any case, you should open an issue at Issues · platformio/platformio-docs · GitHub.

1 Like