Hi, I cannot said hy this funtion cannot work in the first ifdef! can you help me pls?
void debugShow( String debugSwitch, String fonction, String texte){
#ifdef debugSwitch
Serial.println("Fonction: " + fonction + " - " + texte);
#else
#ifdef debug
Serial.println("debugSwitch non déclaré: " + debugSwitch);
#endif
#endif
}
system
February 4, 2019, 9:27pm
2
Hi, I cannot said hy this funtion cannot work in the first ifdef! can you help me pls?
No, sorry, I can't even understand you.
You need to post ALL of your code.
i found my peoblem! unfrontally. i cannot test the first srting variable because this is one compiler instruction ! i've replaced by this and it works now:
void debugShow( String debugSwitch, String fonction, String texte){
#ifdef debugPrint
if(debugSwitch == "debugPrint"){Serial.println("Fonction: " + fonction + " - " + texte); }
#endif
#ifdef debugBoutons
if(debugSwitch == "debugBoutons"){Serial.println("Fonction: " + fonction + " - " + texte); }
#endif
#ifdef debugPir
if(debugSwitch == "debugPir"){Serial.println("Fonction: " + fonction + " - " + texte); }
#endif
#ifdef debugDisplay
if(debugSwitch == "debugDisplay"){Serial.println("Fonction: " + fonction + " - " + texte); }
#endif
#ifdef debugAtmo
if(debugSwitch == "debugAtmo"){Serial.println("Fonction: " + fonction + " - " + texte); }
#endif
#ifdef debugRelay
if(debugSwitch == "debugRelay"){Serial.println("Fonction: " + fonction + " - " + texte); }
#endif
#ifdef debug
if(debugSwitch == "debug"){Serial.println("debugSwitch non déclaré: " + debugSwitch); }
#endif
}
thank you
system
February 5, 2019, 3:40pm
4
The value in debugSwitch is NOT known at compile time. The names that ifdef sees AT COMPILE TIME must have values that are known AT COMPILE TIME.
You are completely misusing ifdef.
PaulS:
You are completely misusing ifdef.
Yes is right but it works fine now!
Have you another way to make the same?