I am defining some values in the preprocessor. e.g.
#defin开发者_运维技巧e a 1000
#define b 0.5*a
When I try to use b in a place where integer is needed I get an error. I don't want to cast b
always in my code and do it once in the #define
line, is that possible?
Try this:
#define a 1000
#define b (a/2)
#define b ((int)(a * 0.5))
精彩评论