Re: Pro*C - nice coding techniques

From: matthew tarrant <matt_at_cernvax.cern.ch>
Date: 13 Feb 92 14:47:10 GMT
Message-ID: <9574_at_cernvax.cern.ch>


In <1992Feb5.125602.15658_at_uqvax.cc.uq.oz.au> ccdavid_at_uqvax.cc.uq.oz.au writes: [stuff deleted]
>I don't like using explicit declarations e.g. char str[50];
>because magic nubers (i.e. 50) suk, esp. when they are likely to
>change often. I need to #define magic numbers for use in the code
>*and* have them hard coded in the SQL declaration. This becomes
>awkward when there are 200+ variables. Also, it doesn't lend itself
>to the use of structures very well (my main gripe).
[more stuff deleted]

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! Received on Thu Feb 13 1992 - 15:47:10 CET

Original text of this message