Re: Incompatible library : Missing Magic Block

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: "Massa, Harald Armin" <chef(at)ghum(dot)de>
Cc: A(dot)Bhattacharya(at)sungard(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: Incompatible library : Missing Magic Block
Date: 2009-10-23 11:02:50
Message-ID: 4AE18D5A.9000502@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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.

--
Craig Ringer

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2009-10-23 11:07:53 Re: FATAL error could not find function "alt_to_mic" in file cyrillic_and_mic.so
Previous Message Jayaraman, Rajaram (STSD) 2009-10-23 10:51:27 Re: FATAL error "could not find function "alt_to_mic" in file cyrillic_and_mic.so