cramer@optilink.UUCP (Clayton Cramer) (07/26/88)
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
ddb@ns.UUCP (David Dyer-Bennet) (07/26/88)
In article <306@optilink.UUCP>, cramer@optilink.UUCP (Clayton Cramer) writes: > [Discussion of the Microsoft C /Zg option to generate function prototypes] > How are other people using the /Zg option? I use it just once, at the beginning of development, to produce my first set of prototypes for the functions. AFter that I update it manually. Since I always include foo.h in foo.c, if they get out of synch I'll get a compilation error there, so it won't go undetected. (I'm not sure this is better than your system; I hadn't considered setting up what you've got, and will now consider it. But the above describes what I've been doing so far....) -- -- David Dyer-Bennet ...!{rutgers!dayton | amdahl!ems | uunet!rosevax}!umn-cs!ns!ddb ddb@Lynx.MN.Org, ...{amdahl,hpda}!bungia!viper!ddb Fidonet 1:282/341.0, (612) 721-8967 hst/2400/1200/300
evas@euraiv1.UUCP (Eelco van Asperen) (07/27/88)
in article <306@optilink.UUCP>, cramer@optilink.UUCP (Clayton Cramer) says: > 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. I use the /Zg option only to convert existing programs; for each file that exports functions, I create a header-file that contains relevant declarations and the prototypes. This file is included in the file itself to let the compiler check that the prototypes still match the current declarations and in the files that use the functions. Now, if you change a function declaration and forget to update the header-file, the compiler will complain that the prototype does not match the actual declaration. -- Eelco van Asperen. uucp: evas@eurtrx / mcvax!eurtrx!evas #include <inews/filler.h> earn/bitnet: asperen@hroeur5 #include <stdjunk.h> "We'ld like to know a little bit about you for our files" - Mrs.Robinson, Simon & Garfunkel
kneller@cgl.ucsf.edu (Don Kneller) (08/02/88)
In article <306@optilink.UUCP> cramer@optilink.UUCP (Clayton Cramer) writes: >Microsoft C has an option /Zg for automatic generation of function >prototypes. > >[ In makefiles ] 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. You can turn off the old prototypes with a conditional directive. Your .c.e rule can look like: .c.e: echo #ifndef NOPROTOTYPES > $*.tmp cl -AL -c -Zg -DNOPROTOTYPES $*.c >> $*.tmp echo #endif >> $*.tmp updexh $*.tmp $*.e ----- Don Kneller UUCP: ...ucbvax!ucsfcgl!kneller INTERNET: kneller@cgl.ucsf.edu BITNET: kneller@ucsfcgl.BITNET