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 support@ccsinfo.com

writing portable C code while using CCS build in functions

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



Joined: 09 Jul 2009
Posts: 11

View user's profile Send private message

writing portable C code while using CCS build in functions
PostPosted: Thu Jul 09, 2009 9:11 am     Reply with quote

Hi All,

I have just purchased the CCS compiler to use with a PIC16f690. I am trying to figure out the best way going forward of using all the built in functions of the CCS compiler while still writing the code in such a way that if it could be ported to another compiler down the road if necessary.
Not sure if this just means putting the built in functions into a wrapper function. For example there are some great low level functions for i2c but if I ported these to another compiler they would not work.

If anyone has some suggestions it would be much appreciated!!

Thanks in advance.

Mike
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Thu Jul 09, 2009 9:26 am     Reply with quote

If you used CCS functions as they are in your code you would just need to write your own versions if you ever moved to another compiler.

Exceptions are, as far as I know:-

int default to unsigned int8, use your own type def!
standardio inserts tris statements, use fastio or add tris to your version of the function when porting.
functions which accept a single char can accept a string, the compiler will create code to call the function with each char in the const array!, write an equivilent to accept strings.

I am sure there are a lot of other considerations which people will comment on. These ones are what I would consider minor Smile
Most functions you would be able to write your own when porting if one was not supplied.
mikem



Joined: 09 Jul 2009
Posts: 11

View user's profile Send private message

PostPosted: Thu Jul 09, 2009 9:41 am     Reply with quote

Thanks for the reply Wayne_.

>> If you used CCS functions as they are in your code you would just need to write your own versions if you ever moved to another compiler.

You are probably right with this point. Just stick to good coding style and I should be fine.

Cheers
Mike
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Jul 09, 2009 10:55 am     Reply with quote

Writing w/CCS is one of the reasons we (I) use CCS. Some of the functions you would HAVE to write for another compiler are done for you.

I did a project starting with C18... but then when looking at how nicely CCS handles streams w/fprintf and printf... it was more worthwhile to convert the project to CCS as it would have taken as much time to sort out the idiosyncrasies of using C18.

Remember, most other compilers were typically made for another target and ported to the Microchip line. This is good and bad.

When I did that conversion from C18 to CCS doing JUST ENOUGH to get it to compile, I went from 80% usage of PROM space to 49%. I didn't change any of the typedefs from C18 (that were set for 16bit INTs) to CCS. JUST ENOUGH to compile and I got back that much PROM space.

Someday I might have to jump back into C18 or another -- but CCS has some compelling arguments for its use. (and yes, I run into bugs too - but no compiler is without I hear. ;D -- could be worse, could be MS and a double API. Try calling up Bill Gates to complain! )

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Guest








PostPosted: Fri Jul 10, 2009 2:07 am     Reply with quote

Hi Ben,

thanks for your thoughts!! Yet more useful information.
You porting experience from C18 to CCS is quite interesting.
Sounds like I picked a good compiler for the pic line of micros.

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