Re: Use of PRId64 with PostgreSQL functions
От | Tom Lane |
---|---|
Тема | Re: Use of PRId64 with PostgreSQL functions |
Дата | |
Msg-id | 15982.1438377791@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Use of PRId64 with PostgreSQL functions ("Paragon Corporation" <lr@pcorp.us>) |
Ответы |
Re: Use of PRId64 with PostgreSQL functions
|
Список | pgsql-hackers |
"Paragon Corporation" <lr@pcorp.us> writes: > I've been currently suffering an issue in mingw64 with changes made in > PostGIS topology code base. Sadly it only happens to me (compiling in > mingw64) > Issue is when code like this was introduced > appendStringInfo(str, "%s%" PRId64, sep, edge->start_node); > Which uses a PostgreSQL function appendStringInfo - as noted here: > https://trac.osgeo.org/postgis/ticket/3206 Huh. Apparently, whichever Windows compiler you're using defines PRId64 as "d", which surely seems pretty broken. > I noticed a thread in March on pgsql-hackers that discussed int limits > http://www.postgresql.org/message-id/20150331141423.GK4878@alap3.anarazel.de > in PostgreSQL and Andres Freund made this comment which stuck in my head: > " for another we'd need some uglyness to determine the > correct printf modifier for int64_t (can't use PRId64 etc afaics)." > What exactly did he mean by can't use PRId64? That was about the fact that we don't know whether PRId64 is defined as "ld" or "lld" on machines where either of those could legitimately mean a 64-bit int. (And while either would work at runtime in that case, we'd get compiler warnings we don't want if we chose the wrong one.) That problem doesn't apply to Windows AFAIK. However, some googling suggests that PRId64 isn't defined on all Windows build environments, and your report says that there's at least one such environment where it is defined, but wrongly :-(. So that's yet another good reason to stay away from PRId64. You'll notice that it appears nowhere in the Postgres sources. 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. regards, tom lane
В списке pgsql-hackers по дате отправления: