RHEL8 Got error: unknown type name ‘sigjmp_buf’ while compiling C simple code after including pg_type.h

From: "Bonu, Miriam, Sony Music Italy" <miriam(dot)bonu(dot)sme(at)sonymusic(dot)com>
To: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Cc: "Marsan, Francesco, Sony Music Italy" <Francesco(dot)Marsan(at)sonymusic(dot)com>, Massimiliano Calcaterra <patesigeo(at)gmail(dot)com>, CAMPAGNOLO Mauro <mauro(dot)campagnolo(at)soprasteria(dot)com>
Subject: RHEL8 Got error: unknown type name ‘sigjmp_buf’ while compiling C simple code after including pg_type.h
Date: 2023-03-24 11:35:22
Message-ID: VI1PR0202MB289684F0AEB3C2FCD9BB1199A1849@VI1PR0202MB2896.eurprd02.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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
[cid:image001(dot)png(at)01D95E46(dot)B1A85120]

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

Attachment Content-Type Size
test.c text/plain 379 bytes
test_comp1.log application/octet-stream 4.5 KB
test_comp2.log application/octet-stream 68.5 KB
test_comp3.log application/octet-stream 5.3 KB
test_comp4.log application/octet-stream 8.0 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniel Gustafsson 2023-03-24 13:01:49 Re: BUG #17867: pg_dump intermittently hangs
Previous Message Andrey Lizenko 2023-03-24 10:06:49 Re: BUG #17863: Unable to restore dump 12.12 -> 15.2