minow@decvax.UUCP (Martin Minow) (12/14/86)
This is one of a collection of comments on the Draft Standard, posted to comp.lang.c for discussion before I mail a final draft to the Ansi C committee. Each message discusses one problem I have found with the Draft Standard that I feel warrants a "no" vote. Note that this message is my personal opinion, and does not reflect on the opinions of my employer. ---- Problem: Page 75, line 27. An identifier not currently defined as a macro should produce a diagnostic message. Whether or not the diagnostic is fatal should be implementation defined. Page 75, line 32ff. The result of preprocessing character constants should be the same as the result of executing the equivalent statements. A single character constant shall have a negative value if it would have a negative value according to the semantics for character constants given on page 25, line 35. Page 82, line 10ff. An unrecognized #pragma should result in a diagnostic message. ---- Motivation: Page 75, line 27. An identifier not currently defined as a macro should produce a diagnostic message. The "defined()" preprocessing expression may be used to check for definition: #if (defined(foo) ? foo : 0) == 123 The standard should not encourage ``silent'' programming errors in the preprocessor, when it forbids use of an undeclared variable in the language proper. ---- Martin Minow decvax!minow
gwyn@brl-smoke.ARPA (Doug Gwyn ) (12/15/86)
In article <109@decvax.UUCP> minow@decvax.UUCP (Martin Minow) writes: More good ideas that have already been discussed by X3J11 and decided differently (but don't let that stop you from making good arguments for adoption of your suggestions!). Perhaps by summarizing my understanding of the current committee position (UNofficially) I can help you frame counter-arguments: >Page 75, line 27. An identifier not currently defined as a macro should >produce a diagnostic message. Whether or not the diagnostic is fatal >should be implementation defined. (Basically, as I understand it the way to guarantee a diagnostic for a violation is to make the condition a Constraint.) The requirement that an undefined identifier evaluate as 0 is for compatibility with existing practice (Reiser CPP on UNIX). It is hard to imagine that there is much existing code that would depend on a diagnostic being produced, but there is definitely a lot of existing code that depends on the behavior defined in the draft. >Page 75, line 32ff. The result of preprocessing character constants should >be the same as the result of executing the equivalent statements. A single >character constant shall have a negative value if it would have a negative >value according to the semantics for character constants given on page 25, >line 35. I believe the lack of such a guarantee is intended to help cross-compilation environments. Basically, preprocessing arithmetic is done (using long integers) at compile time, and emulating the run-time arithmetic would impose a new burden on implementations. >Page 82, line 10ff. An unrecognized #pragma should result in a diagnostic >message. Sorry, I can't go along with this. The idea of #pragma is advisory, so such directives can generally be ignored.
steele@unc.UUCP (Oliver Steele) (12/19/86)
In article <5456@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes: >In article <109@decvax.UUCP> minow@decvax.UUCP (Martin Minow) writes: > >>Page 82, line 10ff. An unrecognized #pragma should result in a diagnostic >>message. > >Sorry, I can't go along with this. The idea of #pragma is >advisory, so such directives can generally be ignored. This seems contradictory to the spirit of requiring variable declarations. If I misspell a #pragma, I want to _know_, rather than have the compiler assume I meant what I said. If I type '#pragma signle' to force a compiler to use single-precision library routines, I don't want to waste time trying to find out why my code isn't faster than it is any more than I like to waste time debugging a FORTRASH program because I've mispelled a variable name and the compiler's automatically declared it. Obviously I don't want a compiler shouting at me 'unknown pragma: single' when I port the program. Perhaps a '#pragma pragmas (single, foo, bar)' to tell the compiler 'These are the pragmas I mean to use. Don't tell me if you don't know what they mean, but warn me about any other pragmas you don't recognize.' would solve things (in fact, a compiler that silently ignored unrecognized pragmas could go ahead and ignore this one). Sure, it's creeping featurism, but so are pragmas in the first place, and I'd rather have an extra feature than a compiler that ignores potential errors. -- Oliver Steele----------------------------------steele@unc When a tree dies, ...!{decvax,ihnp4}!mcnc!unc!steele plant another in its place. steele%unc@csnet-relay.csnet