hom@hocda.UUCP (H.MORRIS) (02/07/84)
In writing code for an interpreter and similar projects, I have often gnashed my teeth over the fact that you can't make a statement like #if sizeof(char *) > sizeof(int) or #if sizeof(int) == sizeof(long) It would go a long way towards making it possible to write certain difficult code to be portable over a reasonable class of machines (Lets say we forget about DEC-10s and Harris/6's, etc.). Since we can't do such things we certain programs (like loaders) riddled with references to particular machines where it really isn't necessary. I realize, I think that the problem is maintaining pcc with (virtually?) no machine dependencies (so the same pcc is used for a cross-compiler as for the host machine - at least I've see that happen). Now there's talk of pcc being less "dumb"; i.e. "knowing" more about C and/or the particular target machine. If done right, looks like that could be a very positive step. One should also have an unbundled pcc CAPABILITY somewhere. I'm not sure but what m4 has too many bells and whistles added.
keesan@bbncca.ARPA (Morris Keesan) (02/08/84)
---------------------------- Just to keep other people from getting as confused as I was at first, I should point out that in the original article complaining about not being able to use sizeof in a #if line, all occurrences of the string "pcc" should be replaced with the string "cpp" (pcc = Portable C Compiler, cpp = C PreProcessor). Note also that this is highly implementation-dependent, i.e. there is nothing requiring a C compiler to have a separate preprocessor pass, or to call it "cpp". That happens to be the way UN*X does it. -- Morris M. Keesan {decvax,linus,wjh12}!bbncca!keesan keesan @ BBN-UNIX.ARPA
tjt@kobold.UUCP (02/08/84)
So whats wrong with:
if ((sizeof(char *) > sizeof(int)) {
. . .
}
The compiler should evaluate the conditional at compile time and skip
the dead code (although many UNIX C compilers rely on the peephole
optimizer to remove the dead code).
#ifdef and so on should only be necessary for conditionally including
#define's, #include's and declarations which cannot possibly be handled
by an ordinary if.
--
Tom Teixeira, Massachusetts Computer Corporation. Westford MA
...!{ihnp4,harpo,decvax}!masscomp!tjt (617) 692-6200 x275