Xref: utzoo comp.lang.c:36601 comp.software-eng:4945 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!texsun!smunews!necssd!harrison From: harrison@necssd.NEC.COM (Mark Harrison) Newsgroups: comp.lang.c,comp.software-eng Subject: Re: Source File Organization Message-ID: <679@necssd.NEC.COM> Date: 27 Feb 91 19:07:43 GMT References: <1991Feb26.045242.23453@rfengr.com> Organization: NEC America Inc. SSD, Irving, TX Lines: 38 In article <1991Feb26.045242.23453@rfengr.com>, rfarris@rfengr.com (Rick Farris) writes: > I have an enumerated type: > typedef enum { A, B, C, D } CMD; > > and a corresponding array of ascii representations : > char ltrs[] = { 'A', 'B', 'C', 'D' }; > > My problem is: How do I keep the darn things in sync? One way: Have a definition file that builds a header file with the typedef and a C file with the array. I have used this method successfully for things like symbol table string constants and error messages. Example: file foo.def ------------ CMD: A B C D TOKENS: Q X Y generates foo.h: ---------------- typedef enum { A, B, C, D } CMD; typedef enum { Q, X, Y } TOKENS; and foo.c: ---------- char CMD_ltrs[] = { 'A', 'B', 'C', 'D' }; char TOKENS_ltrs[] = { 'Q', 'X', 'Y' }; Awk and Perl are good languages for building tools like this. -- Mark Harrison harrison@necssd.NEC.COM (214)518-5050 {necntc, cs.utexas.edu}!necssd!harrison standard disclaimers apply...