Re: Cannot compile with _FILE_OFFSET_BITS = 64
- From: James Kuyper <jameskuyper@xxxxxxxxxxx>
- Date: Mon, 31 Dec 2007 13:50:41 GMT
Ravishankar S wrote:
"Scott.zhou" <rwxrxrx@xxxxxxxxx> wrote in message....
news:fla6k1$j8h$1@xxxxxxxxxxxxxxxx
25 if (lseek(fd, 4*1024*1024*1024, SEEK_SET) == -1) { // integerNo automatic conversion to 64 bit type is done by compiler. So make it
overflow
explicit by making one of the constants as 64 bit type. This makes entire
expression 64 bit.
=> 4*1024*1024*1024LL // 64 Bit constant made by LL suffix.
That's not sufficient. The above is equivalent to ((((4*1024)*1024)*1024LL). The very first multiplication is safe; but the second one might overflow, depending upon the value of INT_MAX. You could solve this by moving the LL to the second 1024, but I think that's an overly subtle solution; a maintenance programmer might not realize why the exact position of the 'LL' is critical. I'd apply the LL suffix to all 4.
.
- Follow-Ups:
- Re: Cannot compile with _FILE_OFFSET_BITS = 64
- From: Keith Thompson
- Re: Cannot compile with _FILE_OFFSET_BITS = 64
- References:
- Re: Cannot compile with _FILE_OFFSET_BITS = 64
- From: Ravishankar S
- Re: Cannot compile with _FILE_OFFSET_BITS = 64
- Prev by Date: Redirect stdin ?
- Next by Date: Re: Programming in standard c
- Previous by thread: Re: Cannot compile with _FILE_OFFSET_BITS = 64
- Next by thread: Re: Cannot compile with _FILE_OFFSET_BITS = 64
- Index(es):
Relevant Pages
|