One (or two) more for Guy's portability rules
Doug Gwyn <gwyn>
gwyn at brl-tgr.ARPA
Wed Nov 20 00:00:03 AEST 1985
> 24. Develop a consistant method of conditionally compiling machine,
> system, and compiler-dependent segments. Use #if, rather than
> #ifdef to protect yourself against typo's (assuming your preprocessor
> warns you of undefined symbols in #if's).
I don't recommend this practice. The vast majority of properly-
written C source code should be independent of target architecture,
and you are much better off isolating system dependencies in
separate modules (read, files) than sprinkling them throughout
your code. No matter how many #ifdefs you use, the minute your
code written like that moves to a new architecture you have a
tedious job ahead adding zillions of additional cases throughout
a mountain of source code. There is much less work if the actual
applications do not need to be modified due to all the system
dependencies being contained in a handful of known files.
More information about the Comp.lang.c
mailing list