IDE 2.0 compiler Behavior Question from the "New Guy:

Hi folks!

Quick Question; When the IDE compiles code, how does it handle structure that is conditional on a defined value? For example

          #define DEBUG_LEVEL = 8
          
          while Loop() {   
             if  ( DEBUG_LEVEL = 8) {
               // do some debug stuff
             }
          }

When the compiler evaluates the if statement above will it drop the code completely if the condition is false?

I want to have robust debug code in the project that is not included in the production version.

Thanks in advance, and Cheers!

The code that is conditional on the defined value will not be included in the compiled code but you have to write the condition correctly which is not the case in your example

To do what you want you would write something like this

#define DEBUG

void setup()
{
  Serial.begin(115200);
#ifdef DEBUG
  Serial.println("DEBUG");
#endif
  Serial.println("end");
}

void loop()
{
}

Perfect, thanks for helping out the new guy!