Re: Incompatible library : Missing Magic Block - Mailing list pgsql-general

From Merlin Moncure
Subject Re: Incompatible library : Missing Magic Block
Date
Msg-id b42b73150910230843q5304709eq901c5b65cf19edbd@mail.gmail.com
Whole thread Raw
In response to Re: Incompatible library : Missing Magic Block  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-general
On Fri, Oct 23, 2009 at 7:02 AM, Craig Ringer
<craig@postnewspapers.com.au> wrote:
> Massa, Harald Armin wrote:
>> Ambarsih,
>>
>>> // add.cpp : Defines the entry point for the DLL application.
>>
>> are you sure that you using the C-Compiler and not the c++ compiler?
>> As much as I know about defaults, that will be a C++ compiled
>> function, which is something totally different then a C compiled
>> function. (and, to my knowledge, a C++ function is not easily callable
>> by PostgreSQL)
>
> So long as the function uses C linkage (extern "C") it'll be callable
> directly from C++ using dlopen(), LoadLibrary, etc.
>
> A C++ function is callable from C via function pointer even if it has
> C++ linkage, though the C calling convention declared must handle stack
> management, parameter passing and return value popping in the same way
> the C++ calling convention on that compiler does. That means that it's
> unsafe to call a __thiscall C++ member function from C, but otherwise
> it's generally fine so long as the C and C++ compilers default to the
> same calling convention or you explicitly specify it on both ends.

exactly...also c++ exceptions are incompatible with postgres
exceptions iirc, and it's highly advisable to avoid using threads..
also there are a couple of keyword conflicts that are annoying (those
may have been fixed).  those gotchas aside, putting c++ in the backend
is trivially done if you understand difference between c and c++
linkage.

merlin

pgsql-general by date:

Previous
From: Richard Broersma
Date:
Subject: Re: pg 8.4 (Auto)-vacuumlo
Next
From: Nim Li
Date:
Subject: Question of using trigger's OLD in EXECUTE