Re: I need example of c++ function for postgres - Mailing list pgsql-cygwin

From Henshall, Stuart - TNP Southwest
Subject Re: I need example of c++ function for postgres
Date
Msg-id E382B5D8EDE1D6118DBE0008C759BCD601EAAC53@WCPEXCHANGE
Whole thread Raw
In response to I need example of c++ function for postgres  (Yuriy Rusinov <rusinov@quasar.ipa.nw.ru>)
List pgsql-cygwin

Have a look at http://www.postgresql.org/docs/7.3/interactive/xfunc-c.html
You'll almost certainly want to extern "c" any routines you want to call from postgres (this'll stop C++ name mangaling).

Also this is the pgsql-cygwin list, meant for the cygwin MS Windows version of postgres.
I suspect you'll probably find more help on pgsql-general@postgresql.org
hth,
- Stuart
P.S. Sorry about the format change, the disclaimer adder forces it :(

> -----Original Message-----
> From: Yuriy Rusinov [mailto:rusinov@quasar.ipa.nw.ru]
> Sent: 08 July 2003 13:00
> To: pgsql-cygwin@postgresql.org
> Subject: [CYGWIN] I need example of c++ function for postgres
>
>
> Hello, everyone !
>
> I have developed function for postgresql, compile it, make
> .so-file and
> when I try to link this function to a database it was an
> error "Cannot
> find function weight_ave in <file>.so". Here is code of this function:
>
> weight_ave.h :
>
> #ifndef _WEIGHTAVE_H
> #define _WEIGHTAVE_H
>
> double weight_ave (const double* const w, const double* const
> x, int n);
>
> #endif
>
> weight_ave.cpp:
>
> #include "weight_ave.h"
>
> double weight_ave (const double* const w, const double* const
> x, int n)
> {
>     double sumx=0.0;
>     double sumw=0.0;
>     for (int i=0; i<n; i++)
>     {
>         sumx+=w[i]*x[i];
>         sumw+=w[i];
>     }
>     return sumx/sumw;
> }
>
> what files I have to include and which way I have to declare this
> function on include.
>
> Best regards,
> Sincerely yours,
> Yuriy Rusinov.

DISCLAIMER:The information in this message is confidential and may be legally privileged. It is intended solely for the addressee.  Access to this message by anyone else is unauthorised.  If you are not the intended recipient, any disclosure, copying, or distribution of the message, or any action or omission taken by you in reliance on it, is prohibited and may be unlawful.  Please immediately contact the sender if you have received this message in error. Thank you.

pgsql-cygwin by date:

Previous
From: "Clemens Bertram"
Date:
Subject: trouble compiling PHP with PostgreSQL under cygwin
Next
From: "Henshall, Stuart - TNP Southwest"
Date:
Subject: Re: ipc-daemon is necessary for running postgre ?