Hi, I'm currently working on a project and I want to use the C++ template for a function because I need the function to be able to use both int and string. However, when I compiled the code, it shows an error that I think looks like shouldn't be there because the error message told me there's something wrong in a line that is all comments.
Here is the function:
void clearDisplay(){
digitalWrite(D1, LOW);
digitalWrite(D2, LOW);
digitalWrite(D3, LOW);
digitalWrite(D4, LOW);
}
//Error here
template <typename T>
void blinkDisplay(int blinkDelay, void (*function)(T), T arg){
static bool first = true;
static unsigned long initTime;
if(first){
initTime = millis();
}
if(millis() - initTime >= blinkDelay){
clearDisplay();
first = true;
delay(blinkDelay);
}
else{
function(arg);
first = false;
blinkDisplay(blinkDelay, function, arg);
}
}
blinkDisplay<String>(250, &show, "FAIL");
blinkDisplay<int>(500, &show, counter);
And here is the error message:
Arduino: 1.8.15 (Windows 10), Board: "Arduino Uno"
Reaction_Test:69:75: error: expected ')' before ';' token
//Error here
^
exit status 1
expected ')' before ';' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Does anyone know what is causing the problem? I'm a bit frustrated by this.