Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!ut-sally!nather From: nather@ut-sally.UUCP Newsgroups: comp.lang.c Subject: creating .h files (was: Re: preventing unnecessary remakes) Message-ID: <7991@ut-sally.UUCP> Date: Thu, 7-May-87 15:40:14 EDT Article-I.D.: ut-sally.7991 Posted: Thu May 7 15:40:14 1987 Date-Received: Sat, 9-May-87 05:44:47 EDT References: <18346@ucbvax.BERKELEY.EDU> <7973@utzoo.UUCP> <796@rtech.UUCP> <1849@dg_rtp.UUCP> Organization: U. Texas CS Dept., Austin, Texas Lines: 26 Summary: here's one way ... In article <1849@dg_rtp.UUCP>, throopw@dg_rtp.UUCP (Wayne Throop) writes: > > Better still is automatically *creating* the .h file from the .c file. > In such a scheme, a parser would discover every typedef, variable, and > routine declared external, and generate an appropriate declaration in > the .h file. A poor man's version can be had fairly simply by using > conditional macro expansion around declarations to be exported into the > .h file. > I use a single "glob.h" file #included in main.c, which contains all globals, #defines, #includes etc. and then create a file called "sglob.h" to be #included in each separate subroutine file. A simple program (tglob.c) scans the glob.h file, tossing out initializing values and sticking "extern" in front of things that need it. A line in the makefile says that sglob.h depends on glob.h so sglob.h is automatically remade when glob.h is changed. This has worked very well for a couple large programs I've written in modular form. The tglob translator seemed too specialized to post, but I'll mail it to anyone interested. -- Ed Nather Astronomy Dept, U of Texas @ Austin {allegra,ihnp4}!{noao,ut-sally}!utastro!nather nather@astro.AS.UTEXAS.EDU