Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!pmafire!uudell!bigtex!texsun!letni!rwsys!sneaky!gordon From: gordon@sneaky.UUCP (Gordon Burditt) Newsgroups: comp.lang.c Subject: Re: Behavior of #error preprocessor directive Keywords: preprocessor directives ANSI standard Message-ID: <46106@sneaky.UUCP> Date: 11 Jan 91 22:58:55 GMT References: <1192@van-bc.wimsey.bc.ca> <14792@smoke.brl.mil> Organization: Gordon Burditt Lines: 21 >Note that code intended to be compiled (with appropriate conditionalizing) >by both ANSI and pre-ANSI compilers should not use #error, because many >pre-ANSI C preprocessors would terminate fatally upon seeing #error, even >in #ifed-out source code. Thus I tend to still use the kludge > #if SOME_EXPR > #include "*** ERROR -- SOME_EXPR ***" > #endif >which has a more drastic effect than #error anyway. This is one place where trigraphs can be useful: #if SOME_EXPR ??=error "*** ERROR -- SOME_EXPR ***" #endif /* SOME_EXPR */ If it's an ANSI compiler, it recognizes the second line as #error. If it's not an ANSI compiler, it probably doesn't recognize ??= as a trigraph, and will call it an error instead. Gordon L. Burditt sneaky.lonestar.org!gordon