Xref: utzoo comp.lang.c:37245 comp.software-eng:5100 Path: utzoo!attcan!uunet!mcsun!ukc!edcastle!aipna!rjc From: rjc@uk.ac.ed.cstr (Richard Caley) Newsgroups: comp.lang.c,comp.software-eng Subject: Re: Source File Organization Message-ID: Date: 1 Mar 91 23:37:07 GMT References: <1991Feb26.045242.23453@rfengr.com> Sender: news@aipna.ed.ac.uk Organization: Center for Speech Technology Research Lines: 48 In-reply-to: rfarris@rfengr.com's message of 26 Feb 91 04:52:42 GMT In article <1991Feb26.045242.23453@rfengr.com>, Rick Farris (rf) writes: rf> My problem is: How do I keep the darn things in sync? I had to do this for six or seven sets of things in a library. I decided to write a short shell script to write all the code for me. I created a file containing the names and any data to be associated with them and the shell script creats a header and a c file a file called people with... char *name int age fred fred 24 mary mary 30 would give a header person.h containing enum person { pe_NIL= -1, pe_fred=0, pe_mary=1, pe_number=2, }; struct person_rec { char *name; int age; }; struct person_rec person_data; enum person person_with_name(char *name); enum person person_with_age(int age); and a c file person.c contining the definition of person_data and the code for the search routines (left as an exercise for the reader). The Makefile takes care of recreating the files when needed and nothing can get out of step. Also saves lots of tedious coding of access routines which are isomorphic for all the tables. (the reson for having a separate "name" field is that often things have names which are not legal c tokens). -- rjc@cstr.ed.ac.uk