Thread: Can Functions be written in C++ or only C?

Can Functions be written in C++ or only C?

From
"Phillip J. Allen"
Date:
Hi all,

I was reading Bruce Momjian book on PostgreSQL and his chapter on user
created functions stated that functions can be written in SQL, PL/PGSQL,
PL/TCL, PL/Per, and C.  But I have been studying C++ for linux.  So can
I create a  dynamically linked object file  in C++ and reference it in a
function?

Thanks,

Phillip J. Allen
Consulting Geochemist/Geologist
Lima Peru
e-mail: paallen@attglobal.net


Re: Can Functions be written in C++ or only C?

From
Einar Karttunen
Date:
On Tue, Aug 07, 2001 at 07:49:06AM -0500, Phillip J. Allen wrote:
> Hi all,
>
> I was reading Bruce Momjian book on PostgreSQL and his chapter on user
> created functions stated that functions can be written in SQL, PL/PGSQL,
> PL/TCL, PL/Per, and C.  But I have been studying C++ for linux.  So can
> I create a  dynamically linked object file  in C++ and reference it in a
> function?
>
The easiest way is to write C-wrappers around your C++ code.

- Einar Karttunen

Re: Can Functions be written in C++ or only C?

From
Tom Lane
Date:
"Phillip J. Allen" <paallen@attglobal.net> writes:
> So can I create a dynamically linked object file in C++ and reference
> it in a function?

In theory you could, but in practice it's likely to be fairly painful.
IIRC, people have reported that the backend include files are not very
C++ - clean.

BTW, if you can write C++, you can write C ... you just have to remember
which parts of the language not to use.

            regards, tom lane