Re: pgsql function using C++?, or at least C interfacing with C++ lib?

From: "Dann Corbit" <DCorbit(at)connx(dot)com>
To: "Eric Parusel" <lists(at)globalrelay(dot)net>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: pgsql function using C++?, or at least C interfacing with C++ lib?
Date: 2004-10-16 23:21:53
Message-ID: D425483C2C5C9F49B5B7A41F89441547055580@postal.corporate.connx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Eric Parusel
> Sent: Saturday, October 16, 2004 4:12 PM
> To: pgsql-general(at)postgresql(dot)org
> Subject: [GENERAL] pgsql function using C++?, or at least C
> interfacing with C++ lib?
>
>
> Hello,
>
> I've got a C++ library I need to use, and I want to use
> it from a pgsql
> function.
> Would anyone happen to have any examples of how to accomplish
> something
> like this?
> I see examples of C-based functions for pgsql (like dbsize, etc, in
> contrib).
>
> Which way should I go about this?
>
> 1) C based function, calling a C++ library (is this possible?)

If you want to do this, publish an interface in your C++ library with
the interface functions declared as extern "C"

> 2) C++ based function, calling a C++ library (I read in the
> pgsql docs
> that compiling C++ code for use with pgsql is either partially
> incompatible, or just a bad idea?)

C++ calling C++ is not portable because of name mangling. Other than
that, if you use the same compiler there is rarely any problem.

> Also note that I would like to pass the function the
> following arguments: int4, _varchar (array of varchars)
>
> Any help would be appreciated, I'm not incredibly experienced
> in these
> matters.

I would use an extern "C" interface, if I were in your shoes.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Josh Close 2004-10-16 23:55:09 Re: plpgsql loop not returning value
Previous Message Eric Parusel 2004-10-16 23:12:03 pgsql function using C++?, or at least C interfacing with C++ lib?