Re: How can I get rid of "Warning C4307: integral constant overflow"
"_Christopher(M2M)" <m2mm4m-ng@yahoo.co.uk> wrote in message
news:s6adnbDrdPKJVfjbnZ2dnUVZ8ternZ2d@bt.com...
Microsoft Visual Studio 2005 Version 8.0.50727.762 (SP.050727-7600)
How do I get rid of "Warning C4307: '-' : integral constant overflow" from
the following macro?
#define d_ReturnMax(I_iTypeSize)\
( (int64(1)<<((I_iTypeSize*8)-1))-1)
Use uint64 in previous line.
There NO warnings when done as a function:
int64 d_ReturnMax(int64 I_iTypeSize)
{ return (1<<((I_iTypeSize*8)-1))-1;}
Test code:
int64 L_iMaxIntSize=d_ReturnMax(sizeof(int32)); //
L_iMaxIntSize=0x000000007fffffff
int64 L_iMaxIntSize=d_ReturnMax(sizeof(char)); //
L_iMaxIntSize=0x000000000000007f
I tried typecasting around all parts of code i.e. int64(...)/(int64)... I
give up now.
Can anyone else spot something I have missed?
--
From _Christopher (M2M).
RefCode:44CdccTCDf42 V04
void DeadEnds() {for(;;);} // :)
If replying by email please included ##71; on the subject line followed by
your subject, any post without the ##71; tag WILL be deleted. I.e.
"##71; Thank for the help."