tags:

views:

57

answers:

2

Hi,

I am defining some values in the preprocessor. e.g.

#define 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?

+4  A: 

Try this:

#define a 1000
#define b (a/2)
Mark Byers
ok, what if a and b are defined and want to define c as a/b ?
paul simmons
Then you could write: #define c (a/b)
Mark Byers
+3  A: 
#define b ((int)(a * 0.5))
Amarghosh