Last active
December 27, 2016 14:49
-
-
Save pervognsen/d3f49fbce27204b8ba6b3d3ea8e3dafc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
typedef union { | |
struct { char pad_x[31]; int x; } __attribute__((packed)); | |
struct { char pad_y[512]; int y; } __attribute__((packed)); | |
// ... | |
} __attribute__((packed)) overlay; | |
// Macrofied: | |
#define JOIN1(x, y) x##y | |
#define JOIN(x, y) JOIN1(x, y) | |
#define FIELD_OFFSET(field, offset) struct { char JOIN(pad, __LINE__)[offset]; field; } __attribute__((packed)) | |
typedef union { | |
FIELD_OFFSET(int x, 31); | |
FIELD_OFFSET(int y, 500); | |
// ... | |
} __attribute__((packed)) overlay; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment