On Thu, Aug 11, 2005 at 12:51:49PM +0100, Chris Green wrote:
You could of course make all the actual definitions one huge #define and use it in two places with your two sets of EXTERN and INIT defines set differently. This is essentially what I did for my enum/string one.
... and going down this route I have come up with:-
#define CLOCK \ {\ VAR (int, xsize, 54)\ VAR (int, ysize, 54)\ VAR (char, bgcolor[100], "#123456")\ VAR (char, fgcolor[100], "#FFFFFF")\ VAR (bool, iconic, false)\ }
#define VAR(a, b, c) a b;
struct Clk CLOCK; // declare the structure
#undef VAR #define VAR(a, b, c) c,
struct Clk clk = CLOCK; // intialiase the structure
int main(int argc, char * argv[]) { int i; }
Using 'CC -E' (this is a Solaris box) shows the output from the pre-processor to be a correctly declared and initialised struct.