Behavior of #error preprocessor directive
Gordon Burditt
gordon at sneaky.UUCP
Sat Jan 12 09:58:55 AEST 1991
>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
More information about the Comp.lang.c
mailing list