From d11578f30e297e51d52f8784b907b6c2ae034240 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 4 Sep 2020 18:32:43 +0200 Subject: [PATCH] test-sizeof: print pointer sizes This is useful information, I don't know why we forgot to add it there. gcc doesn't like arithemetic on a pointer to a function or void*, so don't print signedness info there. It doesn't matter anyway. C says function pointers can be different... Though I guess our code isn't prepared for that. --- src/test/test-sizeof.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/test-sizeof.c b/src/test/test-sizeof.c index b9d63d6b418..6dee2022e8f 100644 --- a/src/test/test-sizeof.c +++ b/src/test/test-sizeof.c @@ -16,6 +16,11 @@ DISABLE_WARNING_TYPE_LIMITS; +#define info_no_sign(t) \ + printf("%s → %zu bits, %zu byte alignment\n", STRINGIFY(t), \ + sizeof(t)*CHAR_BIT, \ + __alignof__(t)) + #define info(t) \ printf("%s → %zu bits%s, %zu byte alignment\n", STRINGIFY(t), \ sizeof(t)*CHAR_BIT, \ @@ -37,6 +42,12 @@ enum BigEnum2 { }; int main(void) { + int (*function_pointer)(void); + + info_no_sign(function_pointer); + info_no_sign(void*); + info(char*); + info(char); info(signed char); info(unsigned char); -- 2.47.3