Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualWashu

Posted 23 October 2012 - 02:10 PM

That you can read and write from different elements in a union if the elements are structs and have the same prefix structure:

union {
   struct {int x, y; };
   struct {int u, v; };
}

x = 45;
cout << u;

I also like that the library and language is designed in such a way that the compilers can optimize usage of the library really well; gcc can optimize through almost everything in there.


structures declared within an anonymous union are not legal C++. Its a visual studio extension.

-changed wording slightly

#3Washu

Posted 23 October 2012 - 02:10 PM

That you can read and write from different elements in a union if the elements are structs and have the same prefix structure:

union {
   struct {int x, y; };
   struct {int u, v; };
}

x = 45;
cout << u;

I also like that the library and language is designed in such a way that the compilers can optimize usage of the library really well; gcc can optimize through almost everything in there.


structures declared within an anonymous union are not legal C++. Its a visual studio extension.

#2Washu

Posted 23 October 2012 - 01:01 PM

That you can read and write from different elements in a union if the elements are structs and have the same prefix structure:

union {
   struct {int x, y; };
   struct {int u, v; };
}

x = 45;
cout << u;

I also like that the library and language is designed in such a way that the compilers can optimize usage of the library really well; gcc can optimize through almost everything in there.


anonymous structures within an anonymous union are not legal C++. Its a visual studio extension.

#1Washu

Posted 23 October 2012 - 12:43 PM

That you can read and write from different elements in a union if the elements are structs and have the same prefix structure:

union {
   struct {int x, y; };
   struct {int u, v; };
}

x = 45;
cout << u;

I also like that the library and language is designed in such a way that the compilers can optimize usage of the library really well; gcc can optimize through almost everything in there.


anonymous structures within an union are not legal C++. Its a visual studio extension.

PARTNERS