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

#define in project file ? ? ?

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



Joined: 23 Mar 2006
Posts: 197
Location: Lewisburg, WV

View user's profile Send private message

#define in project file ? ? ?
PostPosted: Mon Feb 26, 2007 10:11 am     Reply with quote

Needing to build 6 variants from the same code base, each using a different lookup table. Can I use a separate project file (hence a different name for the .hex file), with a #define somewhere in the project file which will let the compiler know which table to include? Is there a better way?

Still using V3.249

Thanks,
Ken
Ttelmah
Guest







PostPosted: Mon Feb 26, 2007 11:19 am     Reply with quote

Just have one version...
Have your main code, with a #define at the top, saying something like:

#define LOOKUP 1

Then have the the lookup tables in separate files, and have code like:

#if LOOKUP == 1
#include lookup1.h
#elif LOOKUP == 2
#include lookup2.h

etc..
#endif

This way you only have one set of code, and simply setting the lokup 'number', changes which table gets included.

Best Wishes
Guest








PostPosted: Mon Feb 26, 2007 1:14 pm     Reply with quote

Ttelmah, thanks,

but I also want a unique name for the compiled (hex) file for each variant.

I don't want to change a source file, compile, rename the output, and repeat for each build. I lose track too easily.

Ideally, I'd have only one project file which built all the variants, but I've no idea how to do this. So, I'm thinking several (nearly identical) project files will do the trick, just building each one separately.

Suggestion?
Ttelmah
Guest







PostPosted: Mon Feb 26, 2007 4:29 pm     Reply with quote

Do it backwards then.
Have six distinct 'programx.c' files. Each contains just:

#include maincode.c
#include tablex.c

Where 'x' is the corresponding table number, and 'maincode' is everything else (including a prototype for the table).

Then just make a seperate project file to point to each of these files. You will get the output files as 'programn' for each required version.

Best Wishes
Guest








PostPosted: Tue Feb 27, 2007 7:50 am     Reply with quote

Yes, this works - thanks very much.

Ken
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