Tag: 动态函数

Postgresql用户定义了c函数问题

我在我的ubuntu 14.04中使用apt-get命令安装了postgresql .. postgresql 9.4 libpg 9.4.8 我想为动态加载添加用户定义的c函数。 我按照规范准备好了我的c文件和sql函数文件,但主要问题是c文件包含像…这样的标题行。 #include“postgres.h” #include #include“fmgr.h” 我在桌面上有我的文件夹,但没有postgers.h或fmgr.h文件.. 我不知道在我的系统上找到源文件的位置,但我从git下载了整个源代码并添加到同一个文件夹中.. 如果我运行编译命令它显示 postgres_ext.h:47:9: error: unknown type name ‘PG_INT64_TYPE’ typedef PG_INT64_TYPE pg_int64; 我不知道从哪里开始..我应该将我的文件放在任何postgres目录,然后编译或下载源文件是正确的选项? 怎么处理错误..? 请帮助..非常感谢提前。

传递具有未确定数量的参数的函数,并使用可变参数调用它

我想创建一个函数“lazy”,它接受一个具有未确定数量的参数作为参数的函数。 我需要什么类型或必须完成哪些演员表? 然后我想在函数“evaluate”中执行该事情。 然后我如何将之前传递的参数传递给传递函数指针的“lazy”函数? 一些代码来说明我的问题: char *function_I_want_to_call(void *foo, type bar, …); // the arguments are unknown to lazy() and evaluate() typedef struct { ??? func; va_list args; } lazy_fcall; void lazy(lazy_fcall *result, ??? func, …) { // which type do I need here? va_start(result->_args, fund); result->func = func; } void *evaluate(lazy_fcall *to_evaluate) { return to_evaluate->func(expand_args(to_evaluate->args)); […]