Eric Blake wrote:
>> [I wrote]
>>This seems to be a bug in gcc. The off_t argument to lseek is a 64-bit
>>type, but instead of being sign-extended to 64 bits, the value passed
>>(-sizeof(data)) passed is only extended to 32-bits, so is actually
>>+4294967292.
[This is OT for Cygwin, and probabl
> This seems to be a bug in gcc. The off_t argument to lseek is a 64-bit
> type, but instead of being sign-extended to 64 bits, the value passed
> (-sizeof(data)) passed is only extended to 32-bits, so is actually
> +4294967292.
No, it is not a bug in gcc. Read a good book on C, please.
>
> I
> I cannot read the last 4-byte word in a file using lseek + read:
>
> /* file "foo" exists and is large enough - say, 4 MB */
> int fd = open("foo",O_RDONLY|O_BINARY);
> uint32 data;
> /* this succeeds and correctly returns the size of file "foo" minus 4 */
> lseek(fd,-sizeof(data),SEEK_EN
Sam Steingold wrote:
> I cannot read the last 4-byte word in a file using lseek + read:
>
> /* file "foo" exists and is large enough - say, 4 MB */
> int fd = open("foo",O_RDONLY|O_BINARY);
> uint32 data;
> /* this succeeds and correctly returns the size of file "foo" minus 4 */
> lseek(fd,-
I cannot read the last 4-byte word in a file using lseek + read:
/* file "foo" exists and is large enough - say, 4 MB */
int fd = open("foo",O_RDONLY|O_BINARY);
uint32 data;
/* this succeeds and correctly returns the size of file "foo" minus 4 */
lseek(fd,-sizeof(data),SEEK_END);
/* this ret
5 matches
Mail list logo