tbob
Joined: 06 Dec 2006 Posts: 3 Location: Providence, RI
|
Simple function overloading problem |
Posted: Tue May 15, 2007 2:58 pm |
|
|
I'm trying to overload a very simple function I've created. I've tried using a header containing function prototypes, or not using them.
Code: |
short lbatt_light(void);
short lbatt_light(short on_off);
short err_light (short on_off);
short lbatt_light(void)
{
return ~LBATT_IND;
}
short lbatt_light(short on_off)
{
if (TRIS_LBATT_IND == 0)
{
LBATT_IND = ~on_off; // a logical '0' turns the light on
// logical '1' turns it off
return 0;
}
else return 1; // If not configured as an output, return failure
}
void main(void)
{
short light_success;
TRIS_LBATT_IND = 0;
if( lbatt_light() == LIGHT_OFF )
light_success = lbatt_light(LIGHT_ON);
else
light_success = lbatt_light(LIGHT_OFF);
if(light_success)
err_light(LIGHT_ON);
}
|
Very simple LED on/off type code. The warning I get is as follows:
Quote: |
>>> Warning 203 "C:\1GMO1001\main.c" Line 102(1,1): Condition always TRUE
*** Error 165 "C:\1GMO1001\main.c" Line 104(16,17): No overload function matches
*** Error 51 "C:\1GMO1001\main.c" Line 106(1,5): A numeric expression must appear here
|
the lbatt_light() function clearly matches my "short lbatt_light(void)" prototype, so what is the problem here?
thanks for any help! Using compiler v4.011 |
|