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


On 03/28/2014 06:53 AM, Nellis, Kenneth wrote:
> 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:

My advice: You usually do NOT want to compile with -pedantic.  That
option exists for programs that are sticking _strictly_ to the C
standard, but lseek() and off_t are not part of the C standard.  There
is no portable way to be pedantic to the C89 standard and simultaneously
use 64-bit offsets.  The situation is better in C99, since that
introduced 64-bit types.

If you want to use %lld, you have to use C99, not C89; use gcc -std=c99
or gcc -std=gnu99.  By omitting -std, you got gcc's default, which for
now is still -std=c89.

> Wondering how to printf an off_t value without the compiler complaining while
> using -Wall -pedantic.

You can't.  So drop the -pedantic.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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