A question on C programming style
Ross Ridge
ross at contact.uucp
Wed Apr 17 10:54:35 AEST 1991
In article <KERS.91Apr15093213 at cdollin.hpl.hp.com> kers at hplb.hpl.hp.com (Chris Dollin) writes:
>I handle this particular problem by having entries
>for each .h file, treating the includes as ``dependencies'', with a ``touch''
>command as the action: thus, if foo.h includes bar.h and baz.h, I have
>
> foo.h: bar.h baz.h
> touch foo.h
Well I tend to think something on the order of:
fred.o: fred.c foo.h bar.h baz.h
bob.o: bob.c foo.h bar.h baz.h
jane.o: jane.c foo.h bar.h baz.h
is the way to go. It's a better representation of the true depedencies.
But to make this more managable I use a simple make macro:
FOO_H = foo.h bar.h baz.h
fred.o: fred.c $(FOO_H)
bob.o: bob.c $(FOO_H)
jane.o: jane.c $(FOO_H)
This lets you quickly update your makefile when add or remove #include's
from your foo.h file. (It also has the great advantage of letting you
do "FOO_H =" when you get fustrated because every little change to foo.h
causes everything to be recompiled.)
Ross Ridge
Disclaimer: This isn't my idea, I stole it from the GNU CC makefile.
I wonder if this makes this covered by the GNU copyleft? Hmm...
--
Ross Ridge //
"The Great HTMU" [oo]
ross at contact.uucp -()-
ross at watcsc.uwaterloo.ca //
More information about the Comp.lang.c
mailing list