Skip to content

Instantly share code, notes, and snippets.

@ebfe
Created March 14, 2012 07:17
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 ebfe/2034812 to your computer and use it in GitHub Desktop.
Save ebfe/2034812 to your computer and use it in GitHub Desktop.
csizes
/*
* gcc -std=c99 csizes.c -o csizes
*/
#include <stddef.h>
#include <stdio.h>
#define print_size(type) \
printf("%12s = %zd\n", #type, sizeof(type));
int main(void) {
print_size(char);
print_size(short);
print_size(int);
print_size(long int);
print_size(long);
print_size(long long);
print_size(float);
print_size(double);
print_size(long double);
print_size(void *);
print_size(size_t);
print_size(ptrdiff_t);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment