Answer the question
In order to leave comments, you need to log in
Will this code be used when compiling?
Good afternoon!
I have defined such a macro in my code, which is enabled with the flag DEBUG
:
#ifdef DEBUG
#define debug(n) Serial.println("***"+String(n)+"***")
#else
#define debug(n) NULL;
#endif
NULL;
? I mean will it be called String
at all?debug(
"New parameters was applied:\n\tfrequency = " +
String(freq) +
"\n\t duty = " +
String(duty)
);
Answer the question
In order to leave comments, you need to log in
The preprocessor works at the 4th stage of code translation.
The preprocessor operates directly on the strings of the translation module in the form of memory blocks.
The description of your macro shows that although debug
it takes an argument, it does not operate with this argument outside the debug configuration. Anywhere in the call to your macro, a substitution will occur NULL
instead of the entire call.
In fact, you do NULL
n't even need this one as a substitution. Why do you need an abundance of hanging ones in the program code NULL
? If you describe the macro like this:
#ifdef DEBUG
#define debug(n) Serial.println("***"+String(n)+"***")
#else
#define debug(n)
#endif
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question