Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!ucsd!ucbvax!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!icdoc!mybg From: mybg@doc.ic.ac.uk (M Y Ben Gershon) Newsgroups: comp.sys.acorn Subject: Re: C release 3 preprocessor bug ?? Message-ID: <1991May16.125325.15323@doc.ic.ac.uk> Date: 16 May 91 12:53:25 GMT Organization: Department of Computing, Imperial College, University of London, UK. Lines: 31 Nntp-Posting-Host: swan.doc.ic.ac.uk Am I crazy, or is there a subtle bug in C release 3? I am surprised that nobody has mentioned it so far, but the ANSI standard, as far as I can gather, states that if a preprocessor macro is undefined, it is deemed to have a value of 0 (in fact 0L, to be precise). According to the latest K&R, (which is the ANSI version), and Harbison & Steele, a macro defined as being 0 is identical to a macro which is undefined, as above. However, Cv3 treats them differently: If a macro is defined as: #define VAX 0 and we then do: #ifdef VAX #error VAX is defined! #endif the error message will be displayed. By the way, who noticed the section on page 406 of the manual, which describes the use of a pragma to effectively give user-defined non-serious errors? I have just noticed it, and find it very useful! This behaviour seems to be highly non-standard. I discovered it when working on a port from Unix, and it took a long time until I realised that a preprocessor macro was defined, but equal to zero - which the Acorn compiler seems to treat differently to an undefined macro. Does anyone from Acorn wish to comment on this? Michael Ben-Gershon mybg@doc.ic.ac.uk