Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!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: <17420@haddock.ima.isc.com> Date: 15 Aug 90 22:29:09 GMT References: <17377@haddock.ima.isc.com> Reply-To: karl@kelp.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 22 In article mikeg@c3.c3.lanl.gov (Michael P. Gerlek) writes: >it's almost what I want (I missed the #error directive when I looked thru >K&R) -- But it's still ANSI-only... Huh? Read again what I wrote. If you spell it ` #error', with a leading space, then both Classic and ANSI compilers should die at that point (though for different reasons). And the `#include "/-/error_message_here/-/"' hack also works on both dialects, though I prefer the former method. >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... That's what `#error' is for. Note that there's *no* construct which is guaranteed to stop compilation; a `friendly' implementation might decide to delete everything that causes an error (after issuing at least one diagnostic, of course), and add `main(){}' at the end if necessary, so that a compilation never fails. But the vendors know we wouldn't like that, so they don't do it. The same applies to `#error'. Karl W. Z. Heuer (karl@kelp.ima.isc.com or ima!kelp!karl), The Walking Lint