delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/05/24/14:19:32

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-0.1 required=5.0 tests=BAYES_40,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Date: Mon, 24 May 2010 14:19:21 -0400
Message-ID: <AANLkTinavzQEuRTesWoomRcNngGcxXiKk2m2Tv2HArIo@mail.gmail.com>
Subject: cygwin-1.7.5: intptr_t/uintptr_t types and PRI?PTR/SCI?PTR format specfiers are inconsistent
From: Matthew Fluet <matthew DOT fluet AT gmail DOT com>
To: cygwin AT cygwin DOT com
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

/usr/include/stdint.h typedefs intptr_t as "int" and uintptr_t as
"unsigned int".
/usr/include/inttypes.h #defines PRIdPTR as "ld" and PRIoPTR as "lo".
These and the other PRI?PTR and SCN?PTR format specifiers are meant to
be used for the intptr_t and uintptr_t types (thus, making them usable
without needing to know their exact type definitions).

This inconsistency leads to warnings from gcc.  (There is also a
potential calling-convention mismatch, though not on x86.)

[mtf AT fenrirvm-win7 tmp]$ cat z.c
#include <stdio.h>
#include <inttypes.h>

int main(int argc, const char* arg[]) {

  printf("&argc = 0x%08"PRIdPTR"\n", (intptr_t)(&argc));
  printf("&argc = 0x%08"PRIxPTR"\n", (uintptr_t)(&argc));
  return 0;
}
[mtf AT fenrirvm-win7 tmp]$ gcc-3 -Wall z.c
z.c: In function `main':
z.c:6: warning: long int format, int arg (arg 2)
z.c:6: warning: long int format, int arg (arg 2)
z.c:7: warning: long unsigned int format, unsigned int arg (arg 2)
z.c:7: warning: long unsigned int format, unsigned int arg (arg 2)
[mtf AT fenrirvm-win7 tmp]$ gcc-4 -Wall z.c
z.c: In function `main':
z.c:6: warning: format `%08ld' expects type `long int', but argument 2
has type `int'
z.c:6: warning: format `%08ld' expects type `long int', but argument 2
has type `int'
z.c:7: warning: format `%08lx' expects type `long unsigned int', but
argument 2 has type `unsigned int'
z.c:7: warning: format `%08lx' expects type `long unsigned int', but
argument 2 has type `unsigned int'

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019