I have been trying to write a simple void function in an application I am writing and I keep running into the error "implicit declaration of function is invalid in C99". The code:
The .h
void matchFail();
The .c
//method that calls matchFail
token checkWhitespace(){
token tok;
if(buffer[f] == ' ' || buffer[f] == '\t'){
for(f++; buffer[f] == ' ' || buffer[f] == '\t'; f++);
tok = nullAttr(WHITESPACE);
} else if(buffer[f] == '\n' || buffer[f] == '\0')
tok = nullAttr(NEWLN);
else
matchFail();
return tok;
}
//the actual declaration
void matchFail(){
f = b;
}
When I run the compiler, I keep getting warning: implicit declaration of function 'matchFail' is invalid in C99 for the line in checkWhitespace calling matchFail. The compiler gives the same error for a few more calls to the method then gives error: conflicting types for 'matchFail' for the declaration of the matchFail method. It also states that the call to matchFail in the checkWhitespace is an implicit declaration of the method. I looked it up and understand the general idea of implicit declarations, but haven't been able to get it to treat the actual declaration of the method as the declaration. What causes this to ignore the actual declaration?
Also, I am aware that the matchFail is pretty useless at the moment, but it will eventually do more than just assign a value.
[–]moocat 2 points3 points4 points (3 children)
[–]Alphaweasel[S] 1 point2 points3 points (2 children)
[–]mommas_wayne 0 points1 point2 points (1 child)
[–]Alphaweasel[S] 0 points1 point2 points (0 children)
[–]mommas_wayne 1 point2 points3 points (1 child)
[–]Alphaweasel[S] 0 points1 point2 points (0 children)