delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,TW_YG,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <50DF129C.1070501@t-online.de> |
Date: | Sat, 29 Dec 2012 16:56:12 +0100 |
From: | Christian Franke <Christian DOT Franke AT t-online DOT de> |
User-Agent: | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0 SeaMonkey/2.14.1 |
MIME-Version: | 1.0 |
To: | cygwin AT cygwin DOT com |
Subject: | Re: format specifier for long long incompatible to glibc |
References: | <20121229075402 DOT GA23880 AT tansi DOT org> |
In-Reply-To: | <20121229075402.GA23880@tansi.org> |
X-IsSubscribed: | yes |
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 |
Arno Wagner wrote: > Example: > > #include <stdio.h> > > void main() { > long long i; > > i = 10000000000L; > > printf("sizeof long long: %d\n", sizeof(i)); > printf("L specifier: %12Ld\n", i); > printf("q specifier: %12qd\n", i); > printf("ll specifier: %12lld\n", i); > } > > gives: > > sizeof long long: 8 > L specifier: 1410065408 > q specifier: 10000000000 > ll specifier: 10000000000 Using -pedantic helps to catch this, then -std=c99 is required to accept "%lld": $ gcc -Wall -pedantic -std=c99 fmt.c fmt.c: In function 'main': fmt.c:9:3: warning: ISO C does not support the '%Ld' gnu_printf format fmt.c:9:3: warning: ISO C does not support the '%Ld' gnu_printf format fmt.c:10:3: warning: ISO C does not support the 'q' gnu_printf length modifier fmt.c:10:3: warning: ISO C does not support the 'q' gnu_printf length modifier (This shows a minor gcc bug: All format warnings are printed twice, one for builtin printf, one for printf prototype) The MinGW and MinGW-w64 compilers have a similar issue when MinGW stdio is selected: $ cygcheck -f /usr/bin/i686-w64-mingw32-gcc mingw64-i686-gcc-core-4.5.3-6 $ i686-w64-mingw32-gcc -ofmt -D__USE_MINGW_ANSI_STDIO -Wall -static fmt.c $ ./fmt sizeof long long: 8 L specifier: 1410065408 q specifier: %12qd ll specifier: 10000000000 > I think this should be fixed, as it may really mess up things > and, to make matters worse, only shows up when the argument exceeds > the integer value limits, making it potentially hard to find. > The problem is that the gnu_printf format check from gcc assumes the behavior of glibc printf. This needs to be fixed in the compiler sources if another libc is used. The format modifier 'L' exists to select the (12 byte) 'long double' type, for example "%Lf". This also works with Cygwin. Using 'L' in conjunction with 'd' is (AFIAK) non-standard. Adding this to Cygwin might be rejected. > Versions: > cygwin libc: No idea, which package is that thing in? > Installed 12/2012 though, so pretty new. The libc is "newlib" and is part of cygwin1.dll from package cygwin. See vfprintf.c at http://www.sourceware.org/cgi-bin/cvsweb.cgi/src/newlib/libc/stdio/?cvsroot=src Christian -- 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
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |