Re: Creating Menu Items from NSMutableArray
Re: Creating Menu Items from NSMutableArray
- Subject: Re: Creating Menu Items from NSMutableArray
- From: Chris Ridd <email@hidden>
- Date: Mon, 19 Aug 2002 11:18:36 +0100
On 17/8/02 12:23 am, Andrew Pinski <email@hidden> wrote:
>
> A basic C error. The 'int index;' needs to come with all the other
>
> variable declarations at the beginning of the function or block.
>
>
It is not a basic C error, it is basic pre-C99 error.
>
You should be glad this has changed for C99.
While declaring variables "when you need them and no sooner" is a nice idea,
I recently discovered a "feature" of gcc that makes it slightly dangerous.
To wit, if you have a variable declared inside a block in a function/method
that has the same name as a parameter of the function or method, gcc will
not warn you. As a consequence you get bizarre run-time behaviour with some
bits of code using the parameter and the code inside the block using the
local one.
If you declare a variable in function/method scope that has the same name as
a parameter, gcc warns you ("declaration of `x' shadows a parameter")
G++'s behaviour here seems the same as gcc's.
Cheers,
Chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.