Otto said:
I have the following statements
int page.x = page.x * ppiScr.x / 25.4;
int page.y = page.y * ppiScr.y / 25.4;
While VC++ is happy GCC complains the above warning. How can I get rid
of these warnings?
O. Wyss
Your 25.4 is a double! So the compiler uses the / operator for double and so
the result is double! If you want to assign a double to an int there is an
certain amount of data loss(everthing behind the ,). More advanced
compilers warn you about such things. The program should compile anyway!
If want to get rid of the warning(and make the statement more understandable
for others) you have to cast it!
int page.x = (int) (page.x * (ppiScr.x / 25.4));
or
int page.x = static_cast<int> (page.x * (ppiScr.x / 25.4));
besides are you shure that you want to use
int page.x = page.x * ppiScr.x / 25.4;
you are initializing an page.x with page.x * ...
page.x doesn't have any value yet so page.x * ... could be pretty much
anything!
Hope I could help!
DevH