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