From 13b1453843f7cced14093f31ba2aac05a0e0cc43 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Wed, 30 Jan 2019 15:42:46 +0100 Subject: sizeof check --- test/monniaux/sizeof/sizeof.c | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/monniaux/sizeof/sizeof.c (limited to 'test/monniaux/sizeof') diff --git a/test/monniaux/sizeof/sizeof.c b/test/monniaux/sizeof/sizeof.c new file mode 100644 index 00000000..9f283376 --- /dev/null +++ b/test/monniaux/sizeof/sizeof.c @@ -0,0 +1,46 @@ +#include +#include +#include +#include + +#define PRINT_SIZE(t) printf("%s\t%zd\n", #t, sizeof(t)) +#define PRINT_SIZES_INTN(n) \ + PRINT_SIZE(int##n##_t); \ + PRINT_SIZE(uint##n##_t); \ + PRINT_SIZE(int_least##n##_t); \ + PRINT_SIZE(uint_least##n##_t); \ + PRINT_SIZE(int_fast##n##_t); \ + PRINT_SIZE(uint_fast##n##_t) + +typedef void fun(void); + +int main() { + PRINT_SIZE(bool); + PRINT_SIZE(char); + PRINT_SIZE(short); + PRINT_SIZE(int); + PRINT_SIZE(long); + PRINT_SIZE(long long); + + PRINT_SIZE(void*); + PRINT_SIZE(fun*); + + PRINT_SIZE(float); + PRINT_SIZE(double); + PRINT_SIZE(long double); + + PRINT_SIZE(ptrdiff_t); + PRINT_SIZE(size_t); + PRINT_SIZE(wchar_t); + PRINT_SIZE(intptr_t); + PRINT_SIZE(uintptr_t); + PRINT_SIZE(intmax_t); + PRINT_SIZE(uintmax_t); + + PRINT_SIZES_INTN(8); + PRINT_SIZES_INTN(16); + PRINT_SIZES_INTN(32); + PRINT_SIZES_INTN(64); + + return 0; +} -- cgit