View previous topic :: View next topic |
Author |
Message |
miketwo
Joined: 04 Aug 2010 Posts: 24
|
PIC24 variable arguments |
Posted: Tue Sep 14, 2010 4:02 pm |
|
|
Has anyone gotten variable arguments to work on the PIC24? I've tried using this example on their website but that just kicks back an error:
Code: | Undefined identifier -- var_arg |
When I switch var_arg() to va_arg(), I get a reboot every time I call it...
I checked the forums but couldn't find anything besides a post in 2007 saying the 4.xxx compiler should still be considered beta.
Any ideas? |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Sep 15, 2010 12:16 am |
|
|
I haven't tried it, but being a new rarely used feature I wouldn't be too surprised when it contains bug.
The v4 compiler has been quiet stable for about a year now. What is your compiler version number? |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed Sep 15, 2010 12:27 am |
|
|
I found that the variable argument implementation is buggy on the function call side (with V4.112), I wonder if it has ever been tested with recent compiler versions.
Because CCS C, also PCD, uses registers rather than the stack to pass function arguments, the variable argument implementation needs a large overhead of an auxilary address offset table, that has to be filled during function calls. But this part of the code acts completely confused, overwrites data values and calculates odd register offsets that are illegal for a 16-Bit processor.
The large overhead makes the usage of the var arg construct with PCD questionable, you should think about using an alternative method based on pointers.
But you should file a bug report anyway. |
|
![](templates/subSilver/images/spacer.gif) |
miketwo
Joined: 04 Aug 2010 Posts: 24
|
|
Posted: Wed Sep 15, 2010 9:48 am |
|
|
Thanks guys.
@ckielstra -- I'm using 4.111 PCD. I try to keep near the latest version, even though upgrading sometimes causes more problems than not.
@FvM -- Thank you for the explanation. I'm not a coder by formal training, so sometimes it's hard for me to tell the difference between a compiler bug and my own stupidity. I'll submit a bug report. This one should be easy -- "Go try your example." ![Wink](images/smiles/icon_wink.gif) |
|
![](templates/subSilver/images/spacer.gif) |
|