|
|
View previous topic :: View next topic |
Author |
Message |
Ken Johnson
Joined: 23 Mar 2006 Posts: 197 Location: Lewisburg, WV
|
#define in project file ? ? ? |
Posted: Mon Feb 26, 2007 10:11 am |
|
|
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
|
|
Posted: Mon Feb 26, 2007 11:19 am |
|
|
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
|
|
Posted: Mon Feb 26, 2007 1:14 pm |
|
|
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
|
|
Posted: Mon Feb 26, 2007 4:29 pm |
|
|
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
|
|
Posted: Tue Feb 27, 2007 7:50 am |
|
|
Yes, this works - thanks very much.
Ken |
|
|
|
|
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
|