问题
I have a very simple macro for which I want to typecast its output to int
only. How to do that?
#define Numbits(A) (sizeof(A)*CHAR_BIT)
I tried:
#define int Numbits(A)({int val; val = sizeof(A)*CHAR_BIT; return val;})
but it also doesn't work
回答1:
Are you saying that #define Numbits(A) (int)(sizeof(A)*CHAR_BIT)
didn't work?
来源:https://stackoverflow.com/questions/31443484/how-to-typecast-preprocessor-macros-to-output-int