Re: I need example of c++ function for postgres

From: "Henshall, Stuart - TNP Southwest" <shenshall(at)tnp-southwest(dot)co(dot)uk>
To: 'Yuriy Rusinov' <rusinov(at)quasar(dot)ipa(dot)nw(dot)ru>, pgsql-cygwin(at)postgresql(dot)org
Subject: Re: I need example of c++ function for postgres
Date: 2003-07-08 13:16:32
Message-ID: E382B5D8EDE1D6118DBE0008C759BCD601EAAC53@WCPEXCHANGE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)postgresql(dot)org
hth,
- Stuart
P.S. Sorry about the format change, the disclaimer adder forces it :(

> -----Original Message-----
> From: Yuriy Rusinov [mailto:rusinov(at)quasar(dot)ipa(dot)nw(dot)ru]
> Sent: 08 July 2003 13:00
> To: pgsql-cygwin(at)postgresql(dot)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.

Browse pgsql-cygwin by date

  From Date Subject
Next Message Seth Rubin 2003-07-08 18:04:35 Win XP Install README
Previous Message Yuriy Rusinov 2003-07-08 11:59:35 I need example of c++ function for postgres