How can I get rid of "Warning C4307: integral constant overflow"
- From: "_Christopher\(M2M\)" <m2mm4m-ng@xxxxxxxxxxx>
- Date: Tue, 5 Jun 2007 21:31:06 +0100
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)
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."
.
- Follow-Ups:
- Re: How can I get rid of "Warning C4307: integral constant overflow"
- From: Ben Voigt [C++ MVP]
- Re: How can I get rid of "Warning C4307: integral constant overflow"
- From: Norbert Unterberg
- Re: How can I get rid of "Warning C4307: integral constant overflow"
- From: MrAsm
- Re: How can I get rid of "Warning C4307: integral constant overflow"
- Prev by Date: Re: SetWindowsHookEx and WH_MOUSE
- Next by Date: Re: Files
- Previous by thread: Re: easy one
- Next by thread: Re: How can I get rid of "Warning C4307: integral constant overflow"
- Index(es):
Relevant Pages
|