This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]
- From: Brian Inglis <Brian dot Inglis at SystematicSw dot ab dot ca>
- To: cygwin at cygwin dot com
- Date: Thu, 25 May 2017 11:34:33 -0600
- Subject: Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]
- Authentication-results: sourceware.org; auth=none
- References: <592618e3.08179d0a.27b5e.4630@mx.google.com> <592633f6.4436ca0a.dc1a8.58f2@mx.google.com>
- Reply-to: Brian dot Inglis at SystematicSw dot ab dot ca
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