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

Reply via email to