Re: Use of PRId64 with PostgreSQL functions

From: "Paragon Corporation" <lr(at)pcorp(dot)us>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <alvherre(at)2ndquadrant(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Use of PRId64 with PostgreSQL functions
Date: 2015-07-31 22:34:45
Message-ID: 000001d0cbe1$1a706cc0$4f514640$@pcorp.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-07-31 23:43:05 Re: Use of PRId64 with PostgreSQL functions
Previous Message Heikki Linnakangas 2015-07-31 21:46:53 Re: 64-bit XIDs again