andrew@teletron.UUCP (Andrew Scott) (11/21/87)
I am working on a set of C programs in which I need multiple versions of the program to exist at the same time. The versions share a great deal of common code, but have several different functions also. I am looking for some advice on the best way to organize my source files. For example, suppose ProgA and ProgB are composed as follows: ProgA: Prog B: module A module A function A1 function A1 function A2 function A3 module B module B function B1 function B1 function B2 function B2 function B3 function B4 function B5 Each module is composed of a set of logically related functions. I'd like to keep modules organized together within individual files if possible. I'd rather not duplicate the shared code portions by creating separate files for ProgA and ProgB. It would be too easy to make a change to a common function in one file and forget to make the change in another. Using `#ifdef ProgA' type conditional compilation statements is inefficient in that a change to a specific function for ProgA requires a re-build of ProgB also. (Plus variable #defines are awkward when using one Makefile for ProgA & ProgB). The only two methods I've come up with are both against what I consider good progamming style - placing each function in a separate file (there goes the module organization) or #including the common code from other files (I prefer #includes for extern declarations, global #defines and type & structure declarations only). Is there a better way? Andrew