aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/sizeof/sizeof.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/monniaux/sizeof/sizeof.c')
-rw-r--r--test/monniaux/sizeof/sizeof.c46
1 files changed, 46 insertions, 0 deletions
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 <stdio.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <inttypes.h>
+
+#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;
+}