X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-3.1 required=5.0 	tests=AWL,BAYES_00,J_CHICKENPOX_83,RCVD_IN_DNSWL_LOW,SPF_PASS
X-Spam-Check-By: sourceware.org
Message-ID: <49BC958D.2080306@cwilson.fastmail.fm>
Date: Sun, 15 Mar 2009 01:43:41 -0400
From: Charles Wilson <cygwin@cwilson.fastmail.fm>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.19) Gecko/20081209 Thunderbird/2.0.0.19 Mnenhy/0.7.6.666
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: long unsigned int vs. uint32_t again
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

Why does the following give me a warning (with -Wformat=2):

      uint32_t seconds = ...
      uint32_t minutes = ...
      uint32_t hours   = ...
      snprintf(buf, sizeof(buf),
               "%" PRIu32 ":%02" PRIu32 ":%02" PRIu32,
               hours, minutes, seconds);

warning: long unsigned int format, uint32_t arg (arg 4)
                                                    warning: long
unsigned int format, uint32_t arg (arg 5)
                                  warning: long unsigned int format,
uint32_t arg (arg 6)

If you've got a uint32_t, then 'PRIu32' is the correct code to use,
right? What OTHER code could there be for printing unsigned, 32bit,
integers?

cygwin's <inttypes.h> has:
#define PRIu8 "u"
#define PRIu16 "u"
#define PRIu32 "lu"
#define PRIu64 "llu"

and <stdint.h> has
typedef unsigned int uint32_t;

This is on cygwin-1.7.0-43, with gcc-3.4.4-999.  Is it possible that our
inttypes.h should be changed, to use "u" for 8, 16, and 32 bits?  Or is
gcc's -Wformat=2 in 3.4.4 just too strict here -- and should be checking
the actual bitwidths of types against the formats, before assuming that
"lu" doesn't match uint32_t?

--
Chuck

--
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/

