Skip to content

Instantly share code, notes, and snippets.

@mtwilliams
Created February 14, 2018 19:39
Show Gist options
  • Save mtwilliams/625676444152bfc499b52fd228285ed1 to your computer and use it in GitHub Desktop.
Save mtwilliams/625676444152bfc499b52fd228285ed1 to your computer and use it in GitHub Desktop.
#include <cstdint>
#include <cstdio>
#define LABEL(Label) \
(((uint64_t)(#Label"\0" )[0] << 0)\
|((uint64_t)(#Label"\0\0" )[1] << 8)\
|((uint64_t)(#Label"\0\0\0" )[2] << 16)\
|((uint64_t)(#Label"\0\0\0\0" )[3] << 24)\
|((uint64_t)(#Label"\0\0\0\0\0" )[4] << 32)\
|((uint64_t)(#Label"\0\0\0\0\0\0" )[5] << 40)\
|((uint64_t)(#Label"\0\0\0\0\0\0\0" )[6] << 48)\
|((uint64_t)(#Label"\0\0\0\0\0\0\0\0")[7] << 56))
enum Tag : uint64_t {
COLOR = LABEL(COLOR),
BIPED = LABEL(BIPED),
TEXTURE = LABEL(TEXTURE),
ENGINEER = LABEL(ENGINEER)
};
void pp(const Tag tag) {
printf("%#.016llx - \"%.8s\"\n", tag, &tag, &tag);
}
int main(int argc, const char *argv[]) {
pp(Tag::COLOR), pp(Tag::BIPED), pp(Tag::TEXTURE), pp(Tag::ENGINEER);
return 0;
}
@mtwilliams
Copy link
Author

0x000000524f4c4f43 - "COLOR"
0x0000004445504942 - "BIPED"
0x0045525554584554 - "TEXTURE"
0x5245454e49474e45 - "ENGINEER"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment