Re: C++ User-defined functions

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: C++ User-defined functions
Дата
Msg-id 49B55366.6010409@postnewspapers.com.au
обсуждение исходный текст
Ответ на C++ User-defined functions  (George Oakman <oakmang@hotmail.com>)
Ответы Re: C++ User-defined functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: C++ User-defined functions  (George Oakman <oakmang@hotmail.com>)
Список pgsql-general
George Oakman wrote:

> I am trying to write a user-defined function in C++. Most examples are give in plain C. I would be very grafeful for
asample program/code-snippet in C++. 

It's just like any other C/C++ code mixing. You must make sure that any
C-only headers are included within an `extern "C"' block, and declare
any functions that'll be accessed via dlopen() etc as 'extern "C"' too.
You may only use POD types, arrays of POD types, and structs of POD
types (with no methods) in calls to/from C code.

In other words, all PostgreSQL must see is plain C code, but your
'extern "C"' functions may call C++ methods and work with C++ objects
internally.

There's lots more information about this on the Internet. Just look for
generic resources on calling C from C++ and vice versa.

(I don't *think* there are any issues with libstdc++, though you'd
probably have to make sure that no other program linked into Pg brings
in a different version of libstdc++.)

--
Craig Ringer

В списке pgsql-general по дате отправления:

Предыдущее
От: George Oakman
Дата:
Сообщение: C++ User-defined functions
Следующее
От: Umar Farooq
Дата:
Сообщение: PostgreSQL Memory Management