This is the mail archive of the
mailing list for the Cygwin project.
Re: open(O_RDWR) and lseek() fail
- From: Csaba Raduly <rcsaba at gmail dot com>
- To: cygwin list <cygwin at cygwin dot com>
- Date: Fri, 28 Mar 2014 22:06:55 +0100
- Subject: Re: open(O_RDWR) and lseek() fail
- Authentication-results: sourceware.org; auth=none
- References: <20140328093110 dot GA23367 at calimero dot vinschen dot de> <0D835E9B9CD07F40A48423F80D3B5A702CE06F27 at USA7109MB022 dot na dot xerox dot net> <53357393 dot 60603 at redhat dot com>
On Fri, Mar 28, 2014 at 2:05 PM, Eric Blake wrote:
> 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
I can be pedantic under any circumstances :)
> 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.
gcc -std=gnu89 -Wall -pedantic -Wno-long-long
Then you have to cast size_t into unsigned long long and off_t into
long long when printf'ing
size_t x = 10;
printf("%lld\n", (long long)x);
$ gcc -Wall -pedantic -Wno-long-long pedant.c
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple