[comp.lang.c] Grammer discrepancies for external data definitions.

bcase@cup.portal.com (08/10/88)

Hi.  I have a question about the necessity of including a type-specifier for
an external data definition (not a function definition).  It seems that the
ANSI C grammer in the back of the new (2nd edition) K & R book doesn't allow
something like

*i;

to stand for

int *i;

In fact, in the "Summary of changes" section in the back of that book, it says:
"External declarations without any specifiers or qualifiers (just a naked
declarator) are fobidden."  Yet it seems that at least some claimed-ANSI C
compilers accept this and do what you might expect (allocate room for an int).
At least one C++ implementation disallows it.  To those of you with the ANSI
spec sitting in front of you, I ask "what is the correct behavior?"

henry@utzoo.uucp (Henry Spencer) (08/14/88)

In article <8014@cup.portal.com> bcase@cup.portal.com writes:
>"External declarations without any specifiers or qualifiers (just a naked
>declarator) are fobidden."  Yet it seems that at least some claimed-ANSI C
>compilers accept this and do what you might expect (allocate room for an int).
>At least one C++ implementation disallows it.  To those of you with the ANSI
>spec sitting in front of you, I ask "what is the correct behavior?"

The May draft (no, my copy *still* hasn't come, dammit, but I've borrowed
a friend's because time is running out) has the grammar set up in such a
way that at least one storage class specifier ("extern" etc.), type
specifier ("int" etc.), or type qualifier ("const" etc.) must appear.
Some compilers may well accept a more general syntax for the sake of
backwards compatibility.

				Henry Spencer @ U of Toronto Zoology
				uunet!attcan!utzoo!henry henry@zoo.toronto.edu
-- 
Intel CPUs are not defective,  |     Henry Spencer at U of Toronto Zoology
they just act that way.        | uunet!attcan!utzoo!henry henry@zoo.toronto.edu