Jump to content

Boostc: Return Value Check And Switch


Recommended Posts

This code has valid return for any param values. But boostc reports "error: function 'days_per_month' has return type 'char' and must return a value

 

char days_per_month (char month, char year)

{

switch (month)

{

case 2: // february

if (is_leap_year (year))

return 29;

else

return 28;

case 4: // april

case 6: // june

case 9: // september

case 11: // november

return 30;

default:

return 31;

}

}

 

Regards,

Tobias

Link to post
Share on other sites
  • 1 month later...

And here is another example:

 

char bin_to_bcd_high (char bin)
{
   if (bin > 199)
       return 2;
   else if (bin > 99)
       return 1;
   else
       return 0;	
#ifdef _BOOSTC
   return 0; // todo: boostc bug reported, remove when fixed
#endif
}

 

BoostC 1.6 Alpha

 

Regards, Tobias

Link to post
Share on other sites

Oops this one was forgotten. Though it has a very simple workaround. Instead of:

 

char bin_to_bcd_high (char bin)
{
   if (bin > 199)
       return 2;
   else if (bin > 99)
       return 1;
   else
       return 0;	
#ifdef _BOOSTC
   return 0; // todo: boostc bug reported, remove when fixed
#endif
}

 

use:

 

char bin_to_bcd_high (char bin)
{
   if (bin > 199)
       return 2;
   else if (bin > 99)
       return 1;
   return 0;	
}

 

Regards,

Pavel

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...