diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-01-30 15:42:46 +0100 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-01-30 15:42:46 +0100 |
commit | 13b1453843f7cced14093f31ba2aac05a0e0cc43 (patch) | |
tree | e9455dc9202d7f47dac3186194847ef4f4e55c43 /test/monniaux/sizeof | |
parent | dee5eee823eddaefbf5f1a8600f89bd9b558c62e (diff) | |
download | compcert-kvx-13b1453843f7cced14093f31ba2aac05a0e0cc43.tar.gz compcert-kvx-13b1453843f7cced14093f31ba2aac05a0e0cc43.zip |
sizeof check
Diffstat (limited to 'test/monniaux/sizeof')
-rw-r--r-- | test/monniaux/sizeof/sizeof.c | 46 |
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; +} |