Basic use of build_flags

Hello, I am new in Platformio. I have to work with a project done by someone else, and there is some way to work that I don’t understand properly.

  1. In the file platformio.ini, there are these lines:
    [platformio]
    extra_configs = .env

I guess, but I am not sure, that this means that there is another file (.env, so without name only the extension) that has additional configurations and those configurations have the same use, if these configuration would be in platformio.ini file. Am I right?

  1. in the file .env there is a line wrote like this:
    -DEMERGENCY_MODE=1

Do this means that is equivalent to use
#define EMERGENCY_MODE 1
?

What happens with the space, between “-D” and “EMERGENCY_MODE”? is it this space not necessary ? It is so simple like it do not have a space?
There is a doc/Web site where this is clarified?
or I am interpreting this in a wrong way, and DEMERGENCY_MODE is another variable/Constant/Macro than EMERGENCY_MODE?

  1. I tried changing the value to 0, so, like this:
    -DEMERGENCY_MODE=0

But in another part of the program (consist in several files) is in the same situation like before I made the change. Also there is part of the program that work exactly like EMERGENCY_MODE has value=1, So the change I did, doesn’t make any change in the precompilator. And I did not found any file with the sentence “#define EMERGENCY_MODE 1”. Maybe it is a configuration problem and is not working properly, but first I must know if the way I am facing the logic is correct.

Could someone confirm, if my logic is correct?
Thanks in advance

There is no need to guess. We have documentation.

https://docs.platformio.org/en/latest/projectconf/sections/platformio/options/generic/extra_configs.html

https://docs.platformio.org/en/latest/projectconf/sections/env/options/build/build_flags.html

Thanks for the documentation Maxgerhardt,
I am still having the confusion with the space:
-DEMERGENCY_MODE=1

Do this means that is equivalent to use
#define EMERGENCY_MODE 1
?

What happens with the space, between “-D” and “EMERGENCY_MODE”? is it this space not necessary ? Is it so simple like do not have a space?

I didn’t found this information in the documentation.

Not in general. When you build_flags = -DEMERGENCY_MODE=1, PlatformIO sets this is a global compiler flag, and so every file will get essentially a #define EMERGENCY_MODE 1 definition at the start of the file. When you add #define EMERGENCY_MODE 1 only to one file, it is per-definition only visible in that file, and not in other files. Unless you plaster all other files with the same macro definition too.

And yes, space after -D makes no difference, this is ignored by GCC.

So -DABC=1 is the same as -D ABC=1.

Thanks, This is exactly what I need to know