• 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
"Flattened" Compound literals
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"Flattened" Compound literals


  • Subject: "Flattened" Compound literals
  • From: Jean-Denis MUYS <email@hidden>
  • Date: Thu, 29 Mar 2012 14:52:34 +0000
  • Thread-topic: "Flattened" Compound literals

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


  • Follow-Ups:
    • Re: "Flattened" Compound literals
      • From: Scott Ribe <email@hidden>
    • Re: "Flattened" Compound literals
      • From: Eeyore <email@hidden>
  • Prev by Date: moving function by function via keyboard
  • Next by Date: Re: "Flattened" Compound literals
  • Previous by thread: moving function by function via keyboard
  • Next by thread: Re: "Flattened" Compound literals
  • Index(es):
    • Date
    • Thread