Re: Use of PRId64 with PostgreSQL functions - Mailing list pgsql-hackers

From Paragon Corporation
Subject Re: Use of PRId64 with PostgreSQL functions
Date
Msg-id 000001d0cbe1$1a706cc0$4f514640$@pcorp.us
Whole thread Raw
In response to Re: Use of PRId64 with PostgreSQL functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Use of PRId64 with PostgreSQL functions  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Alvaro and Tom,

A big thank you.  That seems to have done the trick.  My compiler warnings
went away and no more syntax errors in the regress tests.  I still have some
regress failures I got to hunt down, but those could be caused by places in
the code I did not replace PRId64 calls or something else.


> Huh.  Apparently, whichever Windows compiler you're using defines
> PRId64 as "d", which surely seems pretty broken.

I think it was only failing on the postgresql function calls.  
The  simple test Sandro Santilli had me run

--- testint.c ---
#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>
int main()
{ int64_t x = 1; printf("%" PRId64, x); return 0;
}


Printed: 1

And this: gcc -Wall -E testint.c | grep '\(printf.*x)\| int64_t;\)'
Returned:
__extension__ typedef long long int64_t; printf("%" "I64d", x);


> You did not say how you're declaring the variable that's being printed
here, but if it's based on the int64 type declared by c.h, you should use
the INT64_FORMAT or INT64_MODIFIER strings declared by c.h/pg_config.h.

The types are defined as:

/* INT64 */
typedef int64_t LWT_INT64;
/** Identifier of topology element */
typedef LWT_INT64 LWT_ELEMID;

in this file.
https://trac.osgeo.org/postgis/browser/trunk/liblwgeom/liblwgeom_topo.h

Anyway thanks again. Very much appreciated.

Regina





pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: 64-bit XIDs again
Next
From: Tom Lane
Date:
Subject: Re: Use of PRId64 with PostgreSQL functions