This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: open(O_RDWR) and lseek() fail


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]