Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: How to force cpp to abort? Message-ID: <17377@haddock.ima.isc.com> Date: 13 Aug 90 02:51:27 GMT References: Reply-To: karl@kelp.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 18 In article mikeg@c3.c3.lanl.gov (Michael P. Gerlek) writes: >[If none of the preprocessor conditions hold, I want to abort. How?] Use `#error put_some_text_here'. This is the ANSI C solution. I presume you also want this to work on pre-ANSI compilers (since you used `#else\n#if' instead of the cleaner `#elif' construct). If you add a leading space, i.e. ` #error', it should be invisible to pre-ANSI compilers that would complain about unknown cpp-control lines. (ANSI allows horizontal whitespace before `#' as well as after.) Then an attempt to compile in a pre-ANSI environment where none of the conditionals holds should get an `illegal character' warning when the `#' is encountered in the next compiler pass. If you insist on aborting during the preprocessor pass, you could use `#include "/-/put_some_text_here/-/", which is what I used to use before `#error' was invented. Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint