adding some build_flags for access in my program, but I am getting some errors. I thought we didn’t need to do anything special with the strings in the platformio.ini file?
main.cpp
snprintf(data, 50, “%s”, CONFIG_API_PROTOCOL);
platformio.ini
build_flags =
-DCONFIG_API_PROTOCOL="https://"
Errors:
: error: ‘https’ was not declared in this scope
src\main.cpp:34:33: note: in expansion of macro ‘CONFIG_API_PROTOCOL’
snprintf(data, 50, “%s%s%s%s”, CONFIG_API_PROTOCOL);
er… it’s a string, so put quotes around it when you use it… 
snprintf(data, 50, “%s%s%s%s”, “CONFIG_API_PROTOCOL”);
1 Like
@pfeerick Thanks. I was head down looking for all sorts of reasons after upgrading from esp 3.3 to esp 4. Didn’t even consider that… HA! We had all this working with #defines in the sdkconfig.h but wanted to move it into platformio.ini with the update. Thanks for the boost.
1 Like
wait…does that mean, the CONFIG_API_PROTOCOL that I set in platformio.ini will be referenced by the sprintf if i put quotes around it? I realized that I had too may %s in the sprintf for this example. Still seems that the string “CONFIG_API_PROTOCOL” will be put into data variable and not the parameter CONFIG_API_PROTOCOL which is “https” in the platformio.ini
snprintf(data, 50, “%s”, “CONFIG_API_PROTOCOL”);
1 Like
Hm… good point… This should work then… or at least does for me on the ESP8266 Arduino platform… surround the -Dname=“string” in single quotes… then when it is inserted by the preprocessor, it should insert "https://"
and thus be happy.
build_flags = '-DCONFIG_API_PROTOCOL="https://"'
1 Like
I made the change you suggested and it seems to be okay. I have another problem now, so I guess this is the answer! Thanks!!
1 Like