Remove declaration-after-statement C warning

Mouse mouse at Rodents-Montreal.ORG
Wed Sep 11 22:20:53 PDT 2013


>>> It's still bad style.
>> Yeah, I actually totally agree.

So do I, in most cases.  I can, sort of, see a place for it in things
like macro expansions, but even then I'd rather open a new block for
the new scope.

> The one bit I would like to have is declarations in for/while loops,
> such as

> 	for (int i = 0; i < MAXSCREENS; i++)

I wish I knew more about the spec.  If that's equivalent to

	int i;
	for (i=0;i<MAXSCREENS;i++)

then I don't like it any better.  But if i goes out of scope at the end
of the loop, then I rather like the idea.  (Even then, though, I'm not
sure I like the syntax, because it looks as though it is going to have
horrible parsing ambiguities in the presence of comma operators or
multiple variable declarations in the init portion.)

I should ask my go-to guy for C questions about this.

/~\ 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