Re: Cannot compile with _FILE_OFFSET_BITS = 64
- From: Ulrich Eckhardt <doomster@xxxxxxxx>
- Date: Mon, 31 Dec 2007 11:32:54 +0100
Scott.zhou wrote roughly:
lseek64(fd, 4*1024*1024*1024, SEEK_SET) // integer overflow
Others already explained what is happening, but I'd suggest another approach
that works without C99's long long type simply cast the expression to
off_t, which will automatically be the correct 64 bit type, regardless of
whether you use C89 or C99.
In this example, although I explicitly define _FILE_OFFSET_BITS 64, i
get the warning"integer overflow" [...]
I hope you also understand where the problem comes from! The point has
nothing to do with lseek() but rather with how C handles arithmetic, in
particular that it doesn't suddenly switch to a bigger integer type.
Uli
.
- Follow-Ups:
- Re: Cannot compile with _FILE_OFFSET_BITS = 64
- From: Richard Tobin
- Re: Cannot compile with _FILE_OFFSET_BITS = 64
- Prev by Date: Re: function returning days of the week
- 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
|