Remove declaration-after-statement C warning

Mouse mouse at Rodents-Montreal.ORG
Thu Sep 12 06:19:11 PDT 2013


>> Whenever possible, variables should be declared at point of first
>> assignment, so that it is clear that they have been initialized.

There's nothing that says a top-of-block declaration can't include an
initializer (to a dummy value if necessary).

>> I know of no plausible SE case for declaring variables way up at the
>> top of the block they are defined in other than tradition.

It does make it easier to find the declaration of a variable when
reading the code: check the top of each containing block, rather than
all code up to the beginning of the containing function.  (Of course,
you'd have to decide whether you consider that a "plausible SE case".)

>> It was originally done that way to make it easier for Fortran
>> compilers, AFAIK.

A C feature was done to make it easier for FORTRAN compilers?  I'm not
sure what that could even _mean_.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse at rodents-montreal.org
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


More information about the xorg-devel mailing list