Path: utzoo!utgpu!watmath!clyde!att!pacbell!ames!husc6!bloom-beacon!mit-vax!josh From: josh@mit-vax.LCS.MIT.EDU (Joshua Marantz) Newsgroups: comp.lang.c++ Subject: Save CPP! Message-ID: <5202@mit-vax.LCS.MIT.EDU> Date: 4 Dec 88 19:25:15 GMT Organization: MIT LCS, Cambridge, MA Lines: 44 >Conditional compilation without cpp: > >const UNIX = TRUE; >const MSDOS = FALSE; > >if (UNIX) { > /* code for UNIX systems only */ >} >else if (MSDOS) { > /* code for MSDOS systems only */ >} > >The compiler could dump the code for the constant conditional >that evaluates FALSE and keep the code that evaluates TRUE. >This is the simplest of optimizations and any compiler that does not >do this should be shot (at least the compiler writer should be :-). This approach often *requires* that you compile with the optimizer on. Otherwise the linker will need to resolve references to all platform-specific routines regardless of which platform it's on. I find it a pain to debug compiler-optimized code in a symbolic debugger. In addition, you may want to take advantage of syntactic extensions offered by specific compilers. For example, the VAX C compiler on VMS allows you to take addresses of constants to facilitate calling VAX run time library routines, which generally take their arguments by reference. Finally, the reality is that not all compilers make that optimization. There are those of us that for one reason or another, still have to use old tools (even after the people that created them have been shot by angry academics :-). The thing I like about CPP is that it seems to work with a base level of functionality on the six different C compilers we use to produce the products we sell. Perhaps if we adopt C++, we will find that all the compilers will accept exactly the same syntax and support the same class libraries, and that those class libraries will be enough to isolate us from the platform's file system, graphics system, and other system services. I doubt that will happen. But if they all support CPP, then I think we'll get by. -Joshua Marantz Viewlogic Systems, Inc.