gpt4 book ai didi

c - Postgresql 9.6 C函数编译错误: elog. h: unknown type 'sigjmp'

转载 作者:太空宇宙 更新时间:2023-11-04 02:31:56 25 4
gpt4 key购买 nike

全部,我正在尝试针对 Postgresql 9.6 编译以下 C 框架。

#include "postgres.h"
#include "fmgr.h"
#include "miscadmin.h"

#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif

PG_FUNCTION_INFO_V1(calculateValHash);
Datum calculateValHash(PG_FUNCTION_ARGS) {

text *t = PG_GETARG_TEXT_P(0);
if ( t ) {
PG_RETURN_INT32(12);
} else {
PG_RETURN_INT32(1);
}

};

以下 gcc 命令返回错误:

gcc -shared -I/usr/include/postgresql/9.6/server -lpq -o ./_build/magick.so pgmagick.c -std=c99 -Wall -Wextra
In file included from /usr/include/postgresql/9.6/server/postgres.h:48:0,
from pgmagick.c:1:
/usr/include/postgresql/9.6/server/utils/elog.h:318:20: error: unknown type name ‘sigjmp_buf’
extern PGDLLIMPORT sigjmp_buf *PG_exception_stack;
^

操作系统:Ubuntu 16.04.1 LTS我还安装了 postgresql-server-dev-9.6。

最佳答案

根据man setjmp

Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

  siglongjmp(): _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_C_SOURCE

尝试在#include "postgres.h" 之前#define _XOPEN_SOURCE

关于c - Postgresql 9.6 C函数编译错误: elog. h: unknown type 'sigjmp',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42162966/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com