Re: Pro*C - nice coding techniques

From: David Koblas <koblas_at_mips.com>
Date: 13 Feb 1992 17:55:50 GMT
Message-ID: <kplc96INN96h_at_spim.mips.com>


In article <9574_at_cernvax.cern.ch> matt_at_cernvax.cern.ch (matthew tarrant) writes:
>To resolve those #defined constants, run the .pc file through
>the C preprocessor first. Sample follows:
>
>$(CC) -E -I/user/lepdev/dev/include $< | grep -v '#' > $*_temp.pc
>$(PCC) $(PCCFLAGS) iname=$*_temp.pc oname=$*.c
>$(RM) $*_temp.pc
>$(CC) $(CFLAGS) -I/user/lepdev/dev/include -c $*.c
>
>The first line is the interesting one: it runs the pc
>files through the C preprocessor (-E), greps to
>remove any lines starting with a '#' added by it,
>(which would otherwise screw up the next pass) and
>stores the results.
>
>It works for me!

Your'e lucky then, I would reccomend changing the line from:

        $(CC) -E -I/user/lepdev/dev/include $< | grep -v '#' > $*_temp.pc to:

        $(CC) -E -I/user/lepdev/dev/include $< | grep -v '^#' > $*_temp.pc

Since the preprocessor only adds lines that start with a '#' sign as the first character. And really you could change the output file name to '$*.i' since you don't need to run it through the C preprocessory again, and of course if your compiler does take the '.i' file names then you could do away with the 'grep' statement all together. Otherwise said (off the top of my head):

.pc.o:

	$(CC) -E $< > ,$*.pc
	$(PCC) $(PCCFLAGS) iname=,$*.pc oname=$*.i
	$(CC) $(CFLAGS) -c $*.i

-- 
name : David Koblas                        domain: koblas_at_mips.com
quote: If you have sex in your car, does that make it a recreational vehicle? Received on Thu Feb 13 1992 - 18:55:50 CET

Original text of this message