Newsgroups: | comp.compilers |
From: | macrakis@osf.org (Stavros Macrakis) |
Organization: | OSF Research Institute |
Date: | Fri, 25 Sep 1992 16:17:36 GMT |
References: | 92-09-048 92-09-160 |
Keywords: | C, syntax, design |
crowl@jade.cs.orst.edu (Lawrence Crowl) writes:
The "constant if condition" approach has two problems.
First, consider the "Whatzit" system. It has a "foobar" routine that I've
got to call to get my program to work. No other system has the "foobar"
routine,...
Yes, this is a problem for all conditional declarations, not just
routines. You want to be able to say statically "foobar only exists if
Whatzit is true". For routines, one approach is to define foobar as a macro:
#define foobar() {if (Whatzit) foobar_routine() else ERROR}
where ERROR is a statically-recognized error. This way the error can be
detectable at compile time. Although I don't like macros in general, they
do have some uses, and are somewhat cleaner than #if's.
Second, the body must be syntactically correct in order to parse
successfully. For most code, this shouldn't be a problem. Unfortunately,
there are some syntactic differences that will arise in systems. The
"shared" storage class of Sequent C comes to mind.
Using preprocessors for compiler workarounds seems reasonable.
Viable alternatives [to cpp] always seem to imply configuration
management systems, language support for generics, etc.
...yes, not bad things, are they?
-s
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.