Skip to content

Instantly share code, notes, and snippets.

@gpakosz
Created November 11, 2015 08:08
Show Gist options
  • Save gpakosz/1d9597ad2518c4248345 to your computer and use it in GitHub Desktop.
Save gpakosz/1d9597ad2518c4248345 to your computer and use it in GitHub Desktop.
printf format string for size_t
#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1800)
#define SIZET_FMT "%Iu"
#elif defined(__linux__) || (defined(_MSC_VER) && (_MSC_VER >= 1800))
#define SIZET_FMT "%zu"
#elif defined(__APPLE__)
#define SIZET_FMT "%zu"
#else
#define SIZET_FMT "%u"
#endif
#include <stdio.h>
int main()
{
size_t size = sizeof(int);
printf("size: " SIZET_FMT "\n", size);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment