Re: Problem of Magic Block in Postgres 8.2

From: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: Pei He <hepeimail(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Problem of Magic Block in Postgres 8.2
Date: 2010-04-02 05:47:30
Message-ID: 20100402144730.9760.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Pei He <hepeimail(at)gmail(dot)com> wrote:

> The extension functions was developed by C++ mixed with C.
> ERROR: incompatible library
> "/home/hepei/bin/Chameleon/lib/libspgist_trie.so": missing magic block
> HINT: Extension libraries are required to use the PG_MODULE_MAGIC macro.

You can use extern "C" blocks for PG_MODULE_MAGIC, PG_FUNCTION_INFO_V1,
and function declarations:

extern "C"
{
#include "postgres.h"
#include "fmgr.h"

PG_MODULE_MAGIC;

PG_FUNCTION_INFO_V1(your_function);
extern Datum your_function(PG_FUNCTION_ARGS);
}

However, you should very carefully use C++ exceptions and destructors
in your module because PostgreSQL uses siglongjmp; C++ unwind semantics
don't work on postgres' errors. You cannot use those C++ features and
postgres' APIs together.

Regards,
---
Takahiro Itagaki
NTT Open Source Software Center

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2010-04-02 06:06:04 Re: [HACKERS] Streaming replication document improvements
Previous Message Josh Berkus 2010-04-02 05:10:25 Re: Compile fail, alpha5 & gcc 4.3.3 in elog.c