Created
May 18, 2011 05:07
-
-
Save cmcbride/978023 to your computer and use it in GitHub Desktop.
This file contains 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
#include <stddef.h> | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <unistd.h> | |
void | |
print_size( char const * const desc, const size_t size ) | |
{ | |
printf(" %10s: %zu bytes\n", desc, size); | |
} | |
#define PRINT_SIZE(T) print_size(#T, sizeof(T)); | |
int | |
main ( void ) { | |
printf("Sanity checks for reference:\n"); | |
PRINT_SIZE(int32_t); | |
PRINT_SIZE(int64_t); | |
puts(""); | |
PRINT_SIZE(size_t); | |
PRINT_SIZE(ssize_t); | |
// PRINT_SIZE(ptrdiff_t); // an alternative to ssize_t | |
puts(""); | |
PRINT_SIZE(int); | |
PRINT_SIZE(short); | |
PRINT_SIZE(long); | |
PRINT_SIZE(long long); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment