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

#Include Naming conventions

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



Joined: 19 Feb 2004
Posts: 23

View user's profile Send private message

#Include Naming conventions
PostPosted: Tue Jan 31, 2012 3:58 am     Reply with quote

I'm tryng to improve the readability and ease of usage on my include files

Currently my include statement looks like this.

#include "C:\Documents and Settings\Zac.ZAC-6227651BFB7\My Documents\Programming\CCS PIC C Released\Battery Tester Rev 5_0\Battery Tester R5.h"

What I'd like to do is break it into two parts where the buld of the path structure is in a define statement, all other include line use that define to shorten the path

example:
#Define _porter_ccs C:\Documents and Settings\Zac.ZAC-6227651BFB7\My Documents\Programming\CCS PIC C Released

#include "_porter_ccs\Battery Tester Rev 5_0\Battery Tester R5.h"

This is a simple example of what i'm trying to do ( actual structure more complicated) BUT
am I one the right track :question: :question: :question:
Can I do what I want
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Tue Jan 31, 2012 4:59 am     Reply with quote

It's more conventional to name include files simply and set the project options search paths to the relevant locations on your directory structure. The problem is a) readability, long path names or even path names at all, are not easily readable and b) portability: paths change depending on where the project is located and where its compiled, therefore paths usually go in the IDEs project options, not in your code.

Library code, drivers for your favourite I2C and SPI peripheral ICs can go in a library directory somewhere handy, e.g. on a network drive, while your own project specific code generally sits in a single directory, maybe with subdirectories in some complex projects.

In general for readability and portability I try to keep it simple. If I see something like:

Code:

#include "somedata.h"
#include "somechip.c"
#include "usb.c"
#include "somecode.c"


I feel a lot happier compared to facing:

Code:

#include "c:\\blah\blah\somestrangecode\somedata.h"
#include ""c:\\blah\blah\blah\oldcodereused\somechip.c"
#include "z:\\stuff\directory\whatever\usb.c"
#include "..\..\someplace\wherever\somecode.c"


Also unfortunately the CCS pre-processing doesn't do macro substitutions inside some macros. Most C pre-processors do, and should, but the CCS one doesn't in many cases. Within strings being just one of those cases. Crying or Very sad

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