Declarations in switches, errors

Walter Murray walter at hpclwjm.HP.COM
Sat Sep 30 04:27:00 AEST 1989


Concerning initialization of variables in a switch statement, please
note that the dpANS only repeats what was spelled out in the original
K&R:

   "Usually the statement that is the subject of a switch is
   compound.  Declarations may appear at the head of this statement,
   but initializations of automatic or register variables are
   ineffective."  Page 203.

And the dpANS document does suggest this as a common situation for a
warning:

   "A block with initialization of an object that has automatic
   storage duration is jumped into."  Section A.5.

Walter Murray
-------------



More information about the Comp.std.c mailing list