home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!hal.com!decwrl!netcomsv!netcom.com!pdh
- From: pdh@netcom.com (Phil Howard )
- Newsgroups: comp.lang.c
- Subject: initialized extern variables, coded in 1 file, used in many
- Message-ID: <1993Jan26.015543.23671@netcom.com>
- Date: 26 Jan 93 01:55:43 GMT
- Organization: Netcom - Online Communication Services (408 241-9760 guest)
- Lines: 47
-
- I want to define a large set of extern variables and I want to define
- them in just one place (one file) so that I don't have any problems
- with things out of sync as I change them (changes of type for existing
- variables, or adding and deleting variables).
-
- For the above would create variables in a header like:
-
- EXTERN long var1;
- EXTERN int var2;
-
- and do
-
- #define EXTERN extern
-
- in all files but the one where they are being exported from. In that
- one file I would do
-
- #define EXTERN
-
- and include the header before the first block. The choice of symbol
- name EXTERN is arbitrary; some other name may be used if consistent.
-
- ---------------- NOW HERE IS THE CATCH ----------------
-
- I want to initialize many (its ok to be required to initialize all)
- of these variables. The problem is that initializers are inconsistent
- with the extern storage class. But the initializers would have to be
- coded in the same file as the types of the variables are coded, i.e.
- the header. That means the initializers would be there for those modules
- using the variables with the extern class.
-
- Also, some of these variables will be very large arrays, and initializing
- them via some code would just not be practical. For example, these arrays
- might be a set of default fonts to be used when font files are not specified
- or not available. 64000 assignment statements does not make much sense.
-
- I've tried using the omitted storage class in all modules. This results
- in the variables and their initial contents to be exported from all modules.
- This results in a lot of large object files and errors in the linker.
-
- Has anyone tackled this organizational problem for C and solved it in some
- way?
- --
- /************************************************************************\
- | Phil Howard, pdh@netcom.com, KA9WGN Spell protection? "1(911)A1" |
- | "It's not broken... it's just functionally challenged" --Phil and Pete |
- \************************************************************************/
-