Created
July 5, 2020 15:10
-
-
Save robbiev/3049753205198bc9960566262b4dd03d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
struct vec4_a { | |
union { float x, r; } a; | |
union { float y, g; } b; | |
union { float z, b; } c; | |
union { float w, a; } d; | |
}; | |
union vec4_b { | |
struct { | |
float x, y, z, w; | |
} axis; | |
struct { | |
float r, g, b, a; | |
} color; | |
float data[4]; | |
}; | |
struct vec4_c { | |
union { | |
struct { | |
float x, y, z, w; | |
} axis_; | |
struct { | |
float r, g, b, a; | |
} color_; | |
} vec3; | |
}; | |
int main(int argc, char *argv[]) { | |
struct vec4_a a = {{1}, {2}, {3}, {4}}; | |
union vec4_b b = {{1, 2, 3, 4}}; | |
struct vec4_c c = {{{1, 2, 3, 4}}}; | |
printf("%zu\n", sizeof (struct vec4_a)); | |
printf("%zu\n", sizeof (union vec4_b)); | |
printf("%zu\n", sizeof (struct vec4_c)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment