Re: An Array of structs
Re: An Array of structs
- Subject: Re: An Array of structs
- From: Jeremy Pereira <email@hidden>
- Date: Fri, 27 Nov 2009 13:30:36 +0000
On 27 Nov 2009, at 11:35, John Love wrote:
>
> 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?
You can't have non constant elements in struct initialisers, testy is not a constant. The error message spells out exactly what the issue is.
This is not, by the way, an NSString specific issue. The following gives the same error
typedef struct Foo
{
int foo;
} Foo;
int anInt = 6;
Foo fooArray[] = {{ anInt }};
Use of the "const" keyword doesn't help.
>
>
> John Love
> Touch the Future! Teach!
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden