Question about Declaration Specifiers

Karl Heuer karl at haddock.ima.isc.com
Tue Feb 27 07:21:26 AEST 1990


In article <750 at umvlsi.ecs.umass.edu> chittamu at umvlsi (Satish Kumar .C) writes:
>The grammar in K & R 2 [implies] we can have declarations of the sort
>	register const int
>	const register int
>	int register const
>etc.

Right.  Mostly for backward compatibility with pre-ANSI C.

>I was always under the impression that the rule had to be
>Declaration_Specifiers : Type_Qualifier Storage_Class_Specifier Type_Specifier

No, in fact the storage class should be the first word (all other orderings
are obsolescent).  Nothing is said about the relative ordering of qualifier
and type specifier, but because of the interaction between qualifiers and `*',
it can be argued that the logical ordering is SCS TS TQ:
	extern int const x;   /* x is a constant int */
	extern int const * p; /* p is a pointer to a constant int */
	extern int * const p; /* p is a constant pointer to an int */
This is my preferred ordering.  Opinions will differ.

Karl W. Z. Heuer (karl at ima.ima.isc.com or harvard!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list