How to typecast preprocessor (macros) to output int

穿精又带淫゛_ 提交于 2019-12-12 03:19:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!