delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/03/28/17:07:16

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:date
:message-id:subject:from:to:content-type; q=dns; s=default; b=x+
6IviEyO9+/Mr38x23Bp2Fr0Jn7jhXlz5m0qcg/WWyaZu9ltKmNmB9PtFeLhBIXSH
2qFTyD9Vn216yRc9upFnujYZ9hNUnW2QQ+Gp+6zDaeK9eZgj7YobaekVGQ1R2OfF
1oehF7TzHcCjDah9aDM7rBlwEaCEwakYtfh704jIc=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:mime-version:in-reply-to:references:date
:message-id:subject:from:to:content-type; s=default; bh=bV/jRG+U
Dt6BDK6lgJxE/B3iAuI=; b=isYfXASFB1ZTJy2cN8EB1RjWis7+3QRVWJroKC/B
OimUKkswVM620Qiq2q5Lh0nlTKT8/a0uLNja6tSBJYuDmJ66pxIDFBMNHbGTsyUV
eKz4YKUCzedHKe8kukJ5DBQ+K/sZ13cQA+F1hIQbDtVsmw27XfoFrYPHTBXxbYTV
+fY=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-qc0-f177.google.com
MIME-Version: 1.0
X-Received: by 10.140.94.227 with SMTP id g90mr3705342qge.58.1396040815730; Fri, 28 Mar 2014 14:06:55 -0700 (PDT)
In-Reply-To: <53357393.60603@redhat.com>
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>
Date: Fri, 28 Mar 2014 22:06:55 +0100
Message-ID: <CAEhDDbA_Y8HKVg3HbVz+=8rxrROdOSBMgfPcuE2Vym8=xFbQJg@mail.gmail.com>
Subject: Re: open(O_RDWR) and lseek() fail
From: Csaba Raduly <rcsaba AT gmail DOT com>
To: cygwin list <cygwin AT cygwin 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

#include <sys/types.h>
#include <stdio.h>

int main()
{
    size_t x = 10;
    printf("%lld\n", (long long)x);
    return 0;
}

Csaba AT assos ~
$ gcc -Wall -pedantic -Wno-long-long pedant.c

Csaba AT assos ~
$

Csaba
-- 
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
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019