• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: "Flattened" Compound literals
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: "Flattened" Compound literals
      • From: Jean-Denis MUYS <email@hidden>
References: 
 >"Flattened" Compound literals (From: Jean-Denis MUYS <email@hidden>)

  • Prev by Date: "Flattened" Compound literals
  • Next by Date: Re: "Flattened" Compound literals
  • Previous by thread: "Flattened" Compound literals
  • Next by thread: Re: "Flattened" Compound literals
  • Index(es):
    • Date
    • Thread