"Flattened" Compound literals
"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