Re: "Flattened" Compound literals
Re: "Flattened" Compound literals
- Subject: Re: "Flattened" Compound literals
- From: Eeyore <email@hidden>
- Date: Thu, 29 Mar 2012 08:02:51 -0700
I'm getting complaints (with clang) if I try either
myRect = {0,0,10,10};
or
myRect = (CGRect){0,0,10,10}
so my guess is that it is some compiler switch. If you want a full list of my configuration settings, I would be happy to send it to you so you can compare to determine which setting is the important one.
Aaron
On Mar 29, 2012, at 7:52 AM, Jean-Denis MUYS wrote:
> I have been using C compound literals for quite some time. I prefer them to the old-style calls to CGRectMake and CGPointMake for example:
>
> CGPoint myPoint = { 10, 20};
> […]
> myPoint = (CGPoint){20, 40};
>
>
> myRect = (CGRect){ myPoint, {400, 200}};
>
> And so on. But I just found out by accident that the compiler accepts the following just fine:
>
> myRect = (CGRect){ 20, 40, 400, 200};
>
> Instead of the more conform:
>
> myRect = (CGRect){{20, 40}, {400, 200}};
>
> So the compiler lets the programmer "flatten" the struct in her compound literals.
> Is this supported by the C99 standard or is this some clang extension? (assuming both forms behave the same).
>
> Jean-Denis
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden