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 CCS Technical Support

Default Parameters in Functions

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



Joined: 04 Aug 2010
Posts: 24

View user's profile Send private message

Default Parameters in Functions
PostPosted: Mon Nov 07, 2011 3:32 pm     Reply with quote

Hello everyone.

First, the versions and such:
-- PCD compiler v4.125 (recently updated from 4.124)
-- MPLAB version 8.80 (recently updated from 8.60)
-- Suite_CCSPic plugin (MPLAB plugin connecting the two) version 2.0.0.13. (recently updated from 2.0.0.7)
-- Compiling for a PIC24FJ256GA110


Now, the problem... All of my functions with optional parameters that were compiling just fine under the previous versions have broke. Here is the smallest example I found to recreate the problem.

I have a function with an optional parameter:
Code:

int defaultParameterCheck(int a,int b,int c=0)
{
   return a+b+c;   
}


However, when I try to call the function without the last parameter:
Code:

   defaultParameterCheck(3,5);


I get the following error:

*** Error 102 "main.c" Line 664(25,26): Expect comma

I would assume this is normal behavior except that when i was compiling with previous versions, this code would not generate any errors. The arguments with default parameters were assigned their defaults. What's the point of default arguments if you're forced to provide them anyway to the function?

There are obvious workarounds but I'd like to know if this is a botched upgrade or if others can reproduce the problem.

Can anyone shed light on the situation?
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Nov 07, 2011 4:30 pm     Reply with quote

According to the CCS page it should be supported. Apparently it's broken in
this version. You might send an email to CCS support to let them know...
_________________
Google and Forum Search are some of your best tools!!!!
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Tue Nov 08, 2011 2:21 am     Reply with quote

Quote:
What's the point of default arguments if you're forced to provide them anyway to the function?


The point of them, as with overloads, is to allow *CCS* to implement some functionality in libraries. Specifically it appears that overloads are supported to allow polymorphism in their float maths library. CCS probably only support, and more to the point test these to the extent that they need to support their own libraries.

Both are extentions to C (borrowed from C++) and are thus totally non-portable. As such I wouldn't, and so far never have, used them. I therefore don't miss them when, for whatever reason, they are not there, or don't work as *I* expect. Disappointment comes from expectation. I suspect that being able to sell these extensions as "features" is just a bonus to CCS.

What I'm saying is its better to stick to C when writing C.

RF Developer
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