Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!van-bc!jtc From: jtc@van-bc.wimsey.bc.ca (J.T. Conklin) Newsgroups: comp.lang.c Subject: Behavior of #error preprocessor directive Keywords: preprocessor directives ANSI standard Message-ID: <1192@van-bc.wimsey.bc.ca> Date: 7 Jan 91 22:26:23 GMT Organization: On the job hunt in Burnaby, B.C., Canada Lines: 48 Is use of the #error preprocessor directive required (or permitted) to halt compilation of a source module. I don't have a copy of the C standard, and K&R2 says nothing much more than the token sequence following the directive will be printed. I ask this because I believe both behaviors (halting or continuing) are useful. But it would be even more useful if both mechanisms were available separately. For example, I currently use #error to halt compilation whenever compile-time consistency checks fail; but it would be useful to use a #warning directive for cases like this: #ifdef M_XENIX #warning Use work around for bug brain dead SCO/Microsoft C compiler ..... #else ..... #endif If the text of the #warning was printed during compilation, it would remind me that I could remove the work around whenever SCO releases a fixed version of their compiler (Granted, that is extremely unlikely :-). I've seen a lot of code with little workarounds that still remain years after the original bug that made the workaround necessary has be squashed. Responsibility for maintaining a piece of software may change hands many times during its life. Proper use of such #warnings might help reduce the burden of software maintenance. Has anyone experimented with user-introduced warning messages in C? In any other language? Do they work, or do programmers neglect to use them? Is there a real need for such a feature? In any case, was anything like my #warning directive discussed during the standardization process? If this turns out to be a good idea, there should be plenty of time to slice it into compilers and get some feel of weather its really worthwhile. When does the standard get reviewed again anyway? '95? '00? --jtc -- J.T. Conklin jtc@wimsey.bc.ca, ...!{uunet,ubc-cs}!van-bc!jtc