Dumb question about build_flags

Hello,

I am new to developing anything that needs to be compiled and trying to figure out what the hell are build_flags are supposed to do.

Lets take this example from the docs:

; Build options
build_flags =
    ${common_env_data.build_flags}
    -DSSID_NAME=HELLO
    -DSSID_PASWORD=WORLD

How would I address SSID_NAME/SSID_PASSWORD from inside my main.cpp file?

Other than being able to see if they are defined, I don’t seem to be able to access those things in my functions.

 #ifdef SSID_NAME
 #ifdef SSID_PASSWORD

You need to create two macros in your program.

#define XSTR(x) #x
#define STR(x) XSTR(x)

Then your code can get the values like

String s = STR(SSID_NAME);

In: platformio.ini
I have:

[platformio]
env_default = esp01

[env:esp01]
platform = espressif8266
framework = arduino
board = esp01
build_flags = '-DaSSID="your_ssid"' '-DaSSID_PASS="your_password"'

In: *.cpp
I have:

void setup() {
//  pinMode(BUILTIN_LED, OUTPUT);
  Serial.begin(115200);

  thing.add_wifi(aSSID, aSSID_PASS); // needs only once

See example here Redirecting...

[env:string_defines]
build_flags = '-DHELLO="World!"' '-DWIFI_PASS="My password"'