delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/05/24/19:36:21

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:message-id:date:from:subject:to:references
:content-type; q=dns; s=default; b=dirbQfHVpIDiVtlRpki6ahz3Z4CFW
rM53JEB9EblLpOnUcqF58zuFgaL2X33erWXH0zWIztQ5ehdTBvtz6xoF6eCKbtem
qGj1ZrNH9BRowQ9VvND1P63+7OU2yKXmQn6e356lHgaBovOhvXWfqLt8ytme+WwB
p5mzYkYr9a1B0w=
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:message-id:date:from:subject:to:references
:content-type; s=default; bh=iLIhjQwvJTFSw/KCKi5RJqgWAe0=; b=Y98
s7Bmt8nVSR6RK4frys3Ti6uvOLFSEE6BTH2vpazp4xDJoWWKeAbDZMIzbowjYLqW
sQ6IZxMskFiX77kreyPhodondNgJEqpnVRB5wCa+QGEPQB2Qj8RIkFw3G7ulreyP
brq0a5A4HVHOkq68fe0nHA/COto5784AHyukiBbo=
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: =?ISO-8859-1?Q?No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=UD:wikipedia.org, aren, aren=e2, H*UA:github.com?=
X-HELO: mail-oi0-f41.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:from:subject:to:references :user-agent; bh=XbsS6Aunl0kFKuxZ/7LSeX+JJIlExfnKpmcDG2mK2sU=; b=aIdlVzNfmHlIax7SK2Be04MtjMVnGpDbHfV0/0Vozoicin1jfJk20vttfZMyRNaLPo mJx6prOU8tF2wVLj/NbRiORtPzbOLHWDz01yilbgioeL2cYy18nhZiNd/mqcYvHoldQj bSs057cirs64BHyQBcl0Nb+GMqLvfOMgHuljAJmTNvgvuQds5St3riMbO6vVzKCO0MZt 5VZehqFpW384xwmDuW2JZK1LqJWJAeSvPXr9mdqISoJiqHFyQIJTmSfClKDtnnrdtB/7 jFh3SipVXgEjrSLHz6+/Ta0uEETkSoB0z03WgfShx2Mffoln+L1kZ+W1v+dq6+IxM7rz Dq2g==
X-Gm-Message-State: AODbwcAqitoIteK1Fh6SVcCXJF/dMQo6cfFAyPYEUCp7lT0oySPQjYln c3AOrWz/KL754wHh
X-Received: by 10.157.61.180 with SMTP id l49mr6548400otc.80.1495668964419; Wed, 24 May 2017 16:36:04 -0700 (PDT)
Message-ID: <592618e3.08179d0a.27b5e.4630@mx.google.com>
Date: Wed, 24 May 2017 16:36:03 -0700 (PDT)
From: Steven Penny <svnpenn AT gmail DOT com>
X-Google-Original-From: Steven Penny
Subject: Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]
To: cygwin AT cygwin DOT com
References: <d252aaae-b298-6fc8-7e5b-8d8be9f27f21 AT redhat DOT com>
User-Agent: Tryst/2.0.1 (github.com/svnpenn/tryst)

On Wed, 24 May 2017 07:33:27, Eric Blake wrote:
> Buggy.  size_t should be printed with %zi, not %i (since size_t and int
> are not necessarily the same type).

Aren’t both wrong? By definition %i is a signed integer, and size_t is unsigned.
So %zu or %llu would be more correct:

http://wikipedia.org/wiki/C_data_types

They all seem to do the job though:

    $ cat alfa.c
    #define __USE_MINGW_ANSI_STDIO 1
    #include <stdio.h>
    int main() {
      size_t bravo = 1;
      printf("%zi %zu %llu\n", bravo, bravo, bravo);
    }

    $ x86_64-w64-mingw32-gcc -o alfa alfa.c

    $ ./alfa
    1 1 1


--
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