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

Source file sharing

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



Joined: 03 Feb 2006
Posts: 13
Location: Minnesota

View user's profile Send private message

Source file sharing
PostPosted: Tue Feb 28, 2006 9:35 am     Reply with quote

Hi - I've been using the CCS compiler off and on for the past 5 years but here's my first question on this board.

I have one file that is common between 4 different builds for 4 different boards. Each board has a different PIC micro. Each build
contains only one "main" file that is different for each build. All files for all the builds are kept in a single folder but there are separate MPLAB
build files for each board.

The common file occasionally needs to call a timing function in the (board specific) main file. The actual timer that's used for this
function is different for each board. That's why it needs to reside in the main file.

I'm trying to come up with a way to get these timing function prototypes into a header than can be #included by the common file.

The other option would be to have different folders for each build and keep the common file in it's own location. This would require a specific header file for each build.

Any comments would be appreciated.
Ttelmah
Guest







PostPosted: Tue Feb 28, 2006 9:48 am     Reply with quote

Have a #define, in each of the main source files, in front of the point you include the common file. Something like:

#define SOURCE (1)

Change the number in each of the source files.

Then in the 'common' file, you can use the the #IF statement, to define the required prototypes. So:

#if SOURCE == 1
void timerfunc_fromSource1(int timer);

If the functions have different names in the different main files, use #define to give them all the same name.
So:

#define timer_func(x) timerfunc_fromSource1(x)

If you do that in each 'if' statement section, in the common section of the file, you can call 'timer_func', and it will correctly be redefined to use the function in the main source.

Best Wishes
Ttelmah
Guest







PostPosted: Tue Feb 28, 2006 11:59 am     Reply with quote

Thanks for the advice it looks like it's going to work.

I guess I was getting a little confused on the scope of the #defines in the individual source files and how they would appear in the included common file.
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