PlatformIO Community

& (ampersand) in a build flag results in OS interpreter error

Hello all,

I’m facing a strange issue when I try to define a macro to something with an & in its value through platformio.ini build_flags.
For example, I want to define:
CONFIG_LV_FONT_DEFAULT to &roboto14, so the line looks like:
But when I try to compile the program, several errors are thrown, and it seems the value without the & is interpreted against the OS interpreter (giving 'roboto_14' is not recognized as an internal or external command, operable program or batch file. on Windows, and sh: 1: roboto_14: not found on Ubuntu).

Is there a special way of defining macro values containing special characters like &? I’ve searched in the documentation, but I couldn’t find anything mentioning this.
I also opened an issue, but I’m starting to think I’m in cause for this error, if so I’ll close it with the explanation:

Thanks in advance, have a good day.

Per Build options — PlatformIO latest documentation

Did you try


Thank you very much for your answer!

Sorry, I wasn’t specific enough: I want the macro CONFIG_LV_FONT_DEFAULT replaced by the address of the variable roboto14 (so once the preprocessor did its job, it gives something like lv_font_t *font = &roboto14, not only a char*.)
I did tried with what you suggested, but:

  • on Windows it seems to works as a string, generating "CONFIG_LV_FONT_DEFAULT=\"/&roboto14\"" in c_cpp_properties.json,
  • on Ubuntu, it generates invalid json in c_cpp_properties.json: "CONFIG_LV_FONT_DEFAULT=\"\&roboto14\""

I hope I’m not too confusing, as I don’t really know if it’s possible.