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

PIC24 variable arguments

 
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

PIC24 variable arguments
PostPosted: Tue Sep 14, 2010 4:02 pm     Reply with quote

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... Confused

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?
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Sep 15, 2010 12:16 am     Reply with quote

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?
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Sep 15, 2010 12:27 am     Reply with quote

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.
miketwo



Joined: 04 Aug 2010
Posts: 24

View user's profile Send private message

PostPosted: Wed Sep 15, 2010 9:48 am     Reply with quote

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