This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: open(O_RDWR) and lseek() fail
- From: "Nellis, Kenneth" <Kenneth dot Nellis at xerox dot com>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Fri, 28 Mar 2014 12:53:31 +0000
- Subject: RE: open(O_RDWR) and lseek() fail
- Authentication-results: sourceware.org; auth=none
- References: <20140328093110 dot GA23367 at calimero dot vinschen dot de>
From: Corinna Vinschen
> It doesn't matter what you use, it matters what the function expects.
> lseek expects off_t per POSIX:
>
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html
>
> and off_t is defined as 64 bit type.
After adding the missing unistd.h and return statements, gcc -Wall still
complains:
x.c: In function âmainâ:
x.c:12:2: warning: format â%dâ expects argument of type âintâ, but argument 2 has type âoff_tâ [-Wformat=]
printf("pos = %d\n",lseek(f, 0l, SEEK_CUR));
^
x.c:12:2: warning: format â%dâ expects argument of type âintâ, but argument 2 has type âoff_tâ [-Wformat=]
So, then, after changing %d to %lld, gcc -Wall -pedantic complains:
x.c: In function âmainâ:
x.c:12:2: warning: ISO C90 does not support the âllâ gnu_printf length modifier [-Wformat=]
printf("pos = %lld\n",lseek(f, 0l, SEEK_CUR));
^
x.c:12:2: warning: ISO C90 does not support the âllâ gnu_printf length modifier [-Wformat=]
Wondering how to printf an off_t value without the compiler complaining while
using -Wall -pedantic.
--Ken Nellis