Skip to content

Instantly share code, notes, and snippets.

@dcharkes
Created June 23, 2020 10:46
Show Gist options
  • Save dcharkes/fafbd37f0a989eb891b237fd5589f026 to your computer and use it in GitHub Desktop.
Save dcharkes/fafbd37f0a989eb891b237fd5589f026 to your computer and use it in GitHub Desktop.
$ clang -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ test.c && ./a.out
int : 4
unsigned int : 4
long : 8
unsigned long : 8
size_t : 8
ssize_t : 8
off_t : 8
wchar_t : 4
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/types.h>
#define TYPE(type) printf("%-20s : %li\n", #type, sizeof(type))
int main(int n, char **argc) {
  TYPE(int);
  TYPE(unsigned int);
  TYPE(long);
  TYPE(unsigned long);
  TYPE(size_t);
  TYPE(ssize_t);
  TYPE(off_t);
  TYPE(wchar_t);
  return 0;
  return sizeof(size_t);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment