From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17649 invoked by alias); 25 May 2017 17:34:36 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 17607 invoked by uid 89); 25 May 2017 17:34:35 -0000 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 Received: from smtp-out-no.shaw.ca (HELO smtp-out-no.shaw.ca) (64.59.134.13) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 May 2017 17:34:34 +0000 Received: from [192.168.1.100] ([174.0.238.184]) by shaw.ca with SMTP id Dwegd3P17ETFpDwehdvC3Q; Thu, 25 May 2017 11:34:36 -0600 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 Subject: Re: bug in lrint [was: FW: Printing long int in C program under cygwin64] Reply-To: Brian.Inglis@SystematicSw.ab.ca To: cygwin@cygwin.com References: <592618e3.08179d0a.27b5e.4630@mx.google.com> <592633f6.4436ca0a.dc1a8.58f2@mx.google.com> Message-ID: Date: Thu, 25 May 2017 17:34:00 -0000 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> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfOr4yxlFBxyA3gV6Ohlroeq4NePpR5sOjaJUvByLoBDEPrtB0v9wzKU0dKDE52GNBacAro6dccYL1pV2vLlKUhrwEij2bMDdt7277PU16/DGdPzYTYto WdNS6HnN/8EvH1Fuerc32gbR+iiB/IJ4wZBFVs/VifDhWTl1TSi3qqjFPg3AkQrtf2mfDTnNngX7rA== X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00412.txt.bz2 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 > 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