[comp.lang.c] creating .h files

nather@ut-sally.UUCP (05/07/87)

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