I came across this while programming and forgetting the brackets after the function call, but I only got a warning, which I overlooked:
main.cpp:7:15: warning: expression result unused [-Wunused-value]
if (i == 0) clearDisplay;
^~~~~~~~~~~~
The same thing happens when just doing
int i = 0;
i;
Why isn't this a compiler error?
#include <iostream>
void clearDisplay(void);
int main(void){
for(int i = 0; i < 2; i++){
if (i == 0) clearDisplay;
}
}
void clearDisplay(void){
std::cout << "test" << std::endl;
}
EDIT:
As opposed to g++ "Calling" function without parenthesis ( not f() but f; ). Why always returns 1? I don't ask why it is implicitly casted to a number but why the compiler doesn't warn me about that like it does with if(i=0)
to if(i==0)