Skip to content

Instantly share code, notes, and snippets.

@olooney
Created August 8, 2011 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olooney/1132452 to your computer and use it in GitHub Desktop.
Save olooney/1132452 to your computer and use it in GitHub Desktop.
Show the sizes of C++ built-in types (useful for 32/64 bit systems)
#include <iostream>
#define SIZE(type) std::cout << #type ": " << sizeof(type) << " bytes\n";
int main(int argc, char** argv ) {
SIZE(char);
SIZE(short);
SIZE(int);
SIZE(long);
SIZE(float);
SIZE(double);
SIZE(void*);
SIZE(NULL);
SIZE(0);
SIZE('\0');
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment