delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/05/25/13:34:55

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:from:subject:reply-to:to:references:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=B1DdaG4stKf7lPyv
qE/UtcVL2uPvZq/Z7CLZRqrlRXVhJZ7eAeZ6IwBxQGcFliOLan6sFpEw5JJnQqKL
hRXAe9b4N2Csioq6OSNTO3/yYClz57GNHfZbe551LeGENzUTFBfO1XNhZqq7+2+y
Bz8HDoEWljwrIxwLYE0uN4YDv8o=
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:from:subject:reply-to:to:references:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=a6fCfx8rYMZRKCx5mUx5hF
ZXhXQ=; b=XhSz4X1Gl4LePwi1aROctCWk8DP/4nPD0pWs2zks87nUMGcKAtvNyn
+4JOcfF9Qf5dc198yqiiLegjveD34xLwrnCxammXsUA4oN3N4VqKcCpuGgWFL0O8
hf8/SbPM5eKpqM47MRGYOlCq6Ud6qkeObPjnqLQcUfsfyZDGPgRx8=
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=-1.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=Hx-spam-relays-external:64.59.134.13, H*RU:64.59.134.13, HContent-Transfer-Encoding:8bit
X-HELO: smtp-out-no.shaw.ca
X-Authority-Analysis: v=2.2 cv=dZbw5Tfe c=1 sm=1 tr=0 a=WqCeCkldcEjBO3QZneQsCg==:117 a=WqCeCkldcEjBO3QZneQsCg==:17 a=IkcTkHD0fZMA:10 a=8pif782wAAAA:8 a=w5aJ8kaLLAry8Qfnm_kA:9 a=QEXdDO2ut3YA:10
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Subject: Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]
Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca
To: cygwin AT cygwin DOT com
References: <592618e3 DOT 08179d0a DOT 27b5e DOT 4630 AT mx DOT google DOT com> <592633f6 DOT 4436ca0a DOT dc1a8 DOT 58f2 AT mx DOT google DOT com>
Message-ID: <f23265a0-9b0d-0f54-672d-f5c99b6e5ca6@SystematicSw.ab.ca>
Date: Thu, 25 May 2017 11:34:33 -0600
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1
MIME-Version: 1.0
In-Reply-To: <592633f6.4436ca0a.dc1a8.58f2@mx.google.com>
X-CMAE-Envelope: MS4wfOr4yxlFBxyA3gV6Ohlroeq4NePpR5sOjaJUvByLoBDEPrtB0v9wzKU0dKDE52GNBacAro6dccYL1pV2vLlKUhrwEij2bMDdt7277PU16/DGdPzYTYto WdNS6HnN/8EvH1Fuerc32gbR+iiB/IJ4wZBFVs/VifDhWTl1TSi3qqjFPg3AkQrtf2mfDTnNngX7rA==
X-IsSubscribed: yes

On 2017-05-24 19:31, Steven Penny wrote:
> On Wed, 24 May 2017 16:36:03, Steven Penny wrote:
>> 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:
> Correcting myself. Here is why you cannot use %zi:
>	$ cat alfa.c
>	#define __USE_MINGW_ANSI_STDIO 1
>	#include <stdio.h>
>	int main() {
>		printf("%zi %zu %llu\n", __SIZE_MAX__, __SIZE_MAX__, __SIZE_MAX__);
>	}
>	$ x86_64-w64-mingw32-gcc -o alfa alfa.c
>	$ ./alfa
>	-1 18446744073709551615 18446744073709551615

I think either 10+ digits or a negative value are adequate indicators
that something may have gone wrong, and -1 is a more compact format for
*_MAX, unless you need to see actual values.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

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