Reputation: 33
I am using the following code:
#include <msp430.h>
int flip(int flip){
if (flip) {flip = 0;}
else {flip = 1;}
return flip;
}
/*...*/
void main(void){
int ctrl = 0;
while(1){
ctrl = flip(ctrl);
}
}
When I attempt to compile I get the error, referring to the line:
ctrl = flip(ctrl);
error #110: expression preceding parentheses of apparent call must have (pointer-to-) function type
I don't understand why the compiler is giving me this error.
Replies are correct: the compiler doesn't like it when I'm using the same name for a variable and a function. Fixed.
Upvotes: 1
Views: 112
Reputation: 6760
The compiler is getting confused because, in your context, flip
refers both to a function and to an int
. You should change the name of the argument to something else.
Upvotes: 5