Path: utzoo!attcan!uunet!cs.utexas.edu!yale!cmcl2!lanl!beta.lanl.gov.!mikeg From: mikeg@c3.c3.lanl.gov (Michael P. Gerlek) Newsgroups: comp.lang.c Subject: Re: How to force cpp to abort? Message-ID: Date: 13 Aug 90 15:27:41 GMT References: <17377@haddock.ima.isc.com> Sender: news@lanl.gov Distribution: comp Organization: Los Alamos National Laboratory, New Mexico Lines: 39 In-reply-to: karl@haddock.ima.isc.com's message of 13 Aug 90 02:51:27 GMT In article <17377@haddock.ima.isc.com>, karl@haddock.ima.isc.com (Karl Heuer) writes: > In article I (Michael P. Gerlek) wrote: > > [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). Yup, bingo. > 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. Most of the email responses I got said the same thing, and it's almost what I want (I missed the #error directive when I looked thru K&R) -- But it's still ANSI-only... So, academic question: from what I understand, #error isn't guaranteed to stop compilation. Can someone tell me why there isn't something like an "#abort error-message-here" directive that *would* terminate? Seems like this'd be really useful... [ M.P.Gerlek (mikeg@lanl.gov) - [ Los Alamos Nat'l Lab / Merrimack College - [ Disclaimer: Yes, Mom, I'll play nice. - [ "My other machine *used* to be an XMP." -