|
|
View previous topic :: View next topic |
Author |
Message |
miketwo
Joined: 04 Aug 2010 Posts: 24
|
Default Parameters in Functions |
Posted: Mon Nov 07, 2011 3:32 pm |
|
|
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: 1933 Location: Norman, OK
|
|
Posted: Mon Nov 07, 2011 4:30 pm |
|
|
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
|
|
Posted: Tue Nov 08, 2011 2:21 am |
|
|
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 |
|
|
|
|
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
|