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: Steven Penny <svnpenn at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Wed, 24 May 2017 16:36:03 -0700 (PDT)
- Subject: Re: bug in lrint [was: FW: Printing long int in C program under cygwin64]
- Authentication-results: sourceware.org; auth=none
- References: <d252aaae-b298-6fc8-7e5b-8d8be9f27f21@redhat.com>
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