| www.delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-Spam-Check-By: | sourceware.org |
| X-Authority-Analysis: | v=1.0 c=1 a=uZvujYp8AAAA:8 a=xe8BsctaAAAA:8 a=gZe-lfvyHSwY_yxWjVkA:9 a=_F0iQthgAvg5lOjPhT0A:7 a=6MBBOGheuzxo876_v-HeXzagFCwA:4 a=eDFNAWYWrCwA:10 a=rPt6xJ-oxjAA:10 |
| Message-ID: | <490B25A9.5010806@byu.net> |
| Date: | Fri, 31 Oct 2008 09:35:05 -0600 |
| From: | Eric Blake <ebb9 AT byu DOT net> |
| User-Agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080914 Thunderbird/2.0.0.17 Mnenhy/0.7.5.666 |
| MIME-Version: | 1.0 |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: cygwin g++ strictness |
| References: | <490A30C8 DOT 5000107 AT sh DOT cvut DOT cz> <001601c93b31$a961b940$4001a8c0 AT mycomputer> <003e01c93b42$e92a17a0$4001a8c0 AT mycomputer> <490AE8A0 DOT 8090009 AT sh DOT cvut DOT cz> <001a01c93b4d$617de150$4001a8c0 AT mycomputer> <490AF1E3 DOT 3020308 AT sh DOT cvut DOT cz> <007401c93b56$ebcfa510$4001a8c0 AT mycomputer> <490B0084 DOT 1070803 AT sh DOT cvut DOT cz> <008a01c93b5a$9338d300$4001a8c0 AT mycomputer> <490B078B DOT 9030007 AT byu DOT net> <20081031135011 DOT GB15518 AT calimero DOT vinschen DOT de> <490B21E9 DOT 80807 AT lysator DOT liu DOT se> |
| In-Reply-To: | <490B21E9.80807@lysator.liu.se> |
| 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 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Peter Rosin on 10/31/2008 9:19 AM:
> main(void)
> {
> int32_t i = 32;
> printf("%d", i);
> return 0;
> }
> $ gcc -c -Wall int.c
> int.c: In function `main':
> int.c:6: warning: int format, int32_t arg (arg 2)
> int.c:6: warning: int format, int32_t arg (arg 2)
>
> What should the format specifier be to not have that warning
> on neither Cygwin nor Linux? (or anywhere for that matter)
http://www.opengroup.org/onlinepubs/009695399/basedefs/inttypes.h.html#tag_13_20
#include <inttypes.h>
int32_t i;
printf("%"PRId32"\n",i);
> If the portable thing to do is casting all printf arguments,
> I'm not sure the remedy is worth the damage. But all those
> warnings are definitely an annoyance...
Those warnings are issued for a reason - int is not guaranteed to be 32
bits. When using a 32-bit type, you should use the 32-bit type specifier
in printf (PRId32, PRIo32, PRIu32, PRIx32, PRIX32) rather than a the int
type specifier ("d", "o", "u", "x", "X"). Note that the PRI* macros are
string constants, and that C and C++ string concatenation rules are in use
here.
- --
Don't work too hard, make some time for fun as well!
Eric Blake ebb9 AT byu DOT net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkkLJakACgkQ84KuGfSFAYAFBgCfR/KGvqcfIFuJkAYdmgdFzU/9
/kYAn08fkA5x8D4uv+Xrk7adHIU8Yn6S
=Lx8a
-----END PGP SIGNATURE-----
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |