public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Brian Inglis <Brian.Inglis@SystematicSw.ab.ca>
To: cygwin@cygwin.com
Subject: Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]
Date: Thu, 25 May 2017 17:34:00 -0000	[thread overview]
Message-ID: <f23265a0-9b0d-0f54-672d-f5c99b6e5ca6@SystematicSw.ab.ca> (raw)
In-Reply-To: <592633f6.4436ca0a.dc1a8.58f2@mx.google.com>

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

  reply	other threads:[~2017-05-25 17:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-24 12:18 FW: Printing long int in C program under cygwin64 Carl Fredrik Forsberg
2017-05-24 12:54 ` bug in lrint [was: FW: Printing long int in C program under cygwin64] Eric Blake
2017-05-24 16:53   ` Erik Bray
2017-05-24 16:57     ` Erik Bray
2017-05-24 17:40       ` Eric Blake
2017-05-24 21:19         ` Carl Fredrik Forsberg
2017-05-26 12:05         ` Erik Bray
2017-05-25  1:31   ` Steven Penny
2017-05-25  7:50     ` Steven Penny
2017-05-25 17:34       ` Brian Inglis [this message]
2017-05-25 19:25     ` Eric Blake
2017-05-26  1:53       ` Steven Penny
2017-05-26  5:01         ` Steven Penny
2017-06-07  9:10   ` Corinna Vinschen
2017-06-19 11:09 Carl Fredrik Forsberg
2017-06-20 11:22 ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f23265a0-9b0d-0f54-672d-f5c99b6e5ca6@SystematicSw.ab.ca \
    --to=brian.inglis@systematicsw.ab.ca \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).