Automatic Function Prototype Generation
Clayton Cramer
cramer at optilink.UUCP
Tue Jul 26 04:45:12 AEST 1988
Microsoft C has an option /Zg for automatic generation of function
prototypes. The theory is that you do something like:
cl /Zg foo.c >foo.e
to generate a foo.e file to include in other modules that reference
functions contained in foo.c. This works. The problem is make files.
If you create a make file that automatically generates the .e files,
it will force remakes of all the files dependent on foo.e -- even if
remaking foo.e doesn't cause any change in foo.e except for the date
and time stamp. My solution to this is a make file for generating the
.e files that looks something like this:
.c.e:
cl -AL -c -Zg $*.c >$*.tmp
updexh $*.tmp $*.e
where "updexh" is a DOS batch file:
if NOT EXIST %2 COPY %1 %2
cmp %1 %2
if ERRORLEVEL 1 goto changed
goto done
:changed
COPY %1 %2
touch %2
:done
seterr 0
where "cmp" is a small program that sets the errorlevel to 0 if the
files exactly match, and to 1 if they don't exactly match.
This works (clumsily), but there are two problems:
1. If you change a function definition in foo.c, and you have included
foo.e in foo.c, you will get complaints that will prevent a compile
from happening, and prevent a new foo.e from being produced.
2. If you are defining a new module, and no corresponding .e file
exists, you have to have an empty .e file if any other modules are
going to reference it.
How are other people using the /Zg option?
Clayton E. Cramer
More information about the Comp.lang.c
mailing list