Created
November 11, 2015 08:08
-
-
Save gpakosz/1d9597ad2518c4248345 to your computer and use it in GitHub Desktop.
printf format string for size_t
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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