Обсуждение: RHEL8 Got error: iso-8859-1 type name ‘sigjmp_buf’ while compiling C simple code after including pg_type.h
RHEL8 Got error: iso-8859-1 type name ‘sigjmp_buf’ while compiling C simple code after including pg_type.h
Hello
I’m doing some practice with libpq libraries and I need your help to solve an issue that appeared after I tried to add “pg_type.h” on my source code.
I’m working on RHEL 8.6 environment, with following libpq:
[pgtestdb]/pgtest/postgres>rpm -q postgresql14-devel
postgresql14-devel-14.7-1PGDG.rhel8.x86_64
To check the problem I’ve created a simple C program, named test.c:
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
/* for ntohl/htonl */
#include <netinet/in.h>
#include <arpa/inet.h>
/* for Postgres */
//#include <setjmp.h>
#include "libpq-fe.h"
//#include "catalog/pg_type.h"
int
main(int argc, char **argv)
{
printf("test!!\n");
return 0;
}
I’m using following command to compile:
cc -o test test.c -I/usr/pgsql-14/include -I/usr/pgsql-14/include/server -L/usr/pgsql-14/lib -lpq -v -std=c99
If I compile this, it works fine (see test_comp1.log):
[pgtestdb]/pgtest/postgres>./test
test
but I remove the comment to //#include "catalog/pg_type.h" I get many errors like: unknown type name ‘uint32’
(see test_comp2.log)
Searching in the internet forums, I found that those errors could be solved by adding "c.h" and "postgres.h"
includes, but, if I do it, I obtain another error: error: unknown type name ‘sigjmp_buf’”
(see test_comp3.log)
I found that a definition of sigjmp_buf’ is included in /usr/include/setjmp.h, so I added the include to “setjmp.h”, but I got same error.
(see test_comp4.log)
Can you please help me to solve this issue?
Thanks and regards,
Miriam
Вложения
"Bonu, Miriam, Sony Music Italy" <miriam.bonu.sme@sonymusic.com> writes: > Im doing some practice with libpq libraries and I need your help to solve an issue that appeared after I tried to addpg_type.h on my source code. Don't include pg_type.h. For client-side code, you want pg_type_d.h instead. That won't contain references to server-internal symbols, but it does contain the type OID macros that I assume you're after. regards, tom lane
R: RHEL8 Got error: unknown type name ‘sigjmp_buf’ while compiling C simple code after including pg_type.h
Hi Tom I've just tested your suggestion and it works fine Thank you very much Miriam -----Messaggio originale----- Da: Tom Lane <tgl@sss.pgh.pa.us> Inviato: venerdì 24 marzo 2023 15:51 A: Bonu, Miriam, Sony Music Italy <miriam.bonu.sme@sonymusic.com> Cc: pgsql-bugs@lists.postgresql.org; Marsan, Francesco, Sony Music Italy <Francesco.Marsan@sonymusic.com>; Massimiliano Calcaterra<patesigeo@gmail.com>; CAMPAGNOLO Mauro <mauro.campagnolo@soprasteria.com> Oggetto: Re: RHEL8 Got error: unknown type name ‘sigjmp_buf’ while compiling C simple code after including pg_type.h EXTERNAL SENDER "Bonu, Miriam, Sony Music Italy" <miriam.bonu.sme@sonymusic.com> writes: > Im doing some practice with libpq libraries and I need your help to solve an issue that appeared after I tried to addpg_type.h on my source code. Don't include pg_type.h. For client-side code, you want pg_type_d.h instead. That won't contain references to server-internalsymbols, but it does contain the type OID macros that I assume you're after. regards, tom lane This email originated from outside of Sony Music. Do not click links or open attachments unless you recognize the senderand know the content is safe.