As a pleasant background task I'm re-programming astime (an X clock) to work more the way I want it to.
It's currently written in ANSI C and shows evidence of different programmers having been involved at different times. Nothing wrong with that but it is a bit inconsistent in the way it does things.
I'm trying to improve its style as well as making it do what I want, so, finally to my questions!
It has *lots* of configuration parameters which specify things like colours of the hands, font to use for text, size of clock, etc. etc. There's something like 50 or so of them.
In the existing code some are globals, some are members of a structure called 'state', there appears to be no good reason for this division.
The problem is how to 'hand them around' between different parts of the code, if they're all globals it's easy to initialise them as well as create them in a file called, say, astime_config.c, this avoids the need to create them and *then* initialise them separately. However, apart from so many globals creating problems of its own, it then requires a 'extern' declaration for every value in a header file so that other source files can access the values.
On the other hand if they're all in a structure (or maybe two or three structures) the structure can be declared in a header file and only a few 'extern' declarations are needed (one for each structure). However initialisation is then messy as it's of the form:-
struct Fred fred = { <lots of numbers and strings> };
where it's difficult to document and keep tabs on all those constants.
Is there a good way around this problem or have I just got to bite the bullet and decide on one or other of the above and go with it?
C++ solutions are just as welcome but I can't see that helping really.