It seems that defines are not a solution to your needs: #define is a directive that can influence compiler behaviour, but is not recognized in a compiled executable.
Instead, you could structure your program to read a configuration file at the very beginning, and dynamically allocate your arrays based on the configuration options stored in this file.
Here is the structure I give to all my applications:
Program starting:
1. Read configuration file from disk
2. Define static and dynamic variables
3. Read parameters from disk
4. Retrieve status of the application (if applicable)
5. Start the GUI
6. End program
In detail:
1. Read configuration file from disk
For this part extensively use the INI files reading and writing them by means of the inifile.fp instrument driver (is in toolbox directory). The INI file is the standard file structure in sections and items: a sample file could be:
[General]
# of stations = 8
# of tests = 4
2. Define static and dynamic variables
In this routine I use calloc to dynamically allocate memory for the program. Keep in mind that calloc can treat arrays of structure: so you can define your own struct that holds all variables related for example to a testing station and allocate the necessary space for them. For example: define the struct in a include file:
tyedef struct { // Define the structure of your variable
int ID;
char SerialNumber;
// other variables needed
} station;
station *s; // Define the variable to be dynamically allocated
Next in the source code allocate memory for your stations:
s = calloc (n_stats, sizeof (station));
3. Read parameters from disk
In this routine I read from disk all variables parameters applicable to my program: in your case maybe some parameters related to stations and tests. Again, I rely on INI files to store informations.
4. Retrieve status of the application (if applicable)
No need for further explanation
5. Start the GUI
The program can start with all static and dynamic variables setup in a proper way
6. End program
Remember to free() all dynamic memory allocated in the program
I hope all this can help you a little
Roberto
Message Edited by Roberto Bozzolo on 06-25-2005 08:06 AM