CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Simple function overloading problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
tbob



Joined: 06 Dec 2006
Posts: 3
Location: Providence, RI

View user's profile Send private message

Simple function overloading problem
PostPosted: Tue May 15, 2007 2:58 pm     Reply with quote

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
kevcon



Joined: 21 Feb 2007
Posts: 142
Location: Michigan, USA

View user's profile Send private message

PostPosted: Tue May 15, 2007 3:03 pm     Reply with quote

According the the version info page, this was fixed in 4.031

http://www.ccsinfo.com/devices.php?page=versioninfo


EDIT:
Although it looks like it doesn't work in 4.037.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group