Skip to content

Instantly share code, notes, and snippets.

@sgqy
Last active December 2, 2019 09:49
Show Gist options
  • Save sgqy/b37f8b47d4629abddb711952aad7ca1c to your computer and use it in GitHub Desktop.
Save sgqy/b37f8b47d4629abddb711952aad7ca1c to your computer and use it in GitHub Desktop.
#include <cstdint>
#include <cstdio>
#define print_size(x) printf("%20s: %2ld byte, %2ld bit\n", #x, sizeof(x), sizeof(x) * 8)
int main()
{
print_size(char);
print_size(short);
print_size(int);
print_size(long);
print_size(long long);
print_size(uint8_t);
print_size(uint16_t);
print_size(uint32_t);
print_size(uint64_t);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment