On 27/11/2009, at 10:35 PM, John Love wrote:

> NSString *testy = @"testy";
> YearAmt gTest[] = {{testy, 10}  /*, + others */};
> 
> I get "Initializer element is not constant. This pertains to the NSString* 
> because if I directly substitute the following, no compile error happens:
> YearAmt gTest[] = {{@"testy", 10}
> 
> What fundamental pertaining to C or C++ am I not getting?


The error tells you - the initialiser is not constant.

Sure, it's constant in the first line, but 'testy' is a variable, so you are 
trying to use a variable as a constant initializer in the second line. That 
isn't allowed.

If you think about how constant initializers in C actually work, at the machine 
code/assembler level, it should be clear why it isn't allowed.

--Graham

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to