From: Zbigniew Jędrzejewski-Szmek Date: Fri, 4 Sep 2020 16:32:43 +0000 (+0200) Subject: test-sizeof: print pointer sizes X-Git-Tag: v247-rc1~282^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16955%2Fhead;p=thirdparty%2Fsystemd.git 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. --- 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);