From: | Sevo Stille <sevo(at)ip23(dot)net> |
---|---|
To: | mathprof(at)bigfoot(dot)com |
Cc: | pgsql-general(at)postgreSQL(dot)org |
Subject: | Re: [GENERAL] Linking in sin() as a C function |
Date: | 2000-02-02 11:17:11 |
Message-ID: | 38981237.91256F11@ip23.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
mathprof(at)bigfoot(dot)com wrote:
>
> Thanks! Based on this, I created a file called "test.c" as follows:
>
> #include <math.h>
> float pg_sin(float *x) {return(sin(*x));}
>
> and compiled it using: "gcc test.c -lm -shared" to create a shared object
> file. I then tried the same steps as below (substituting
> "/usr/lib/libm.so" with the path to my "a.out" file created by gcc), but
> this still didn't work? I'm getting different wrong values, but they're
> still wrong nonetheless?
The return has to be a pointer too. Try:
#include <math.h>
#include "postgres.h"
#include "utils/palloc.h"
float *pg_sin(float *x){
float *f = (float *)palloc(sizeof(float));
*f = sin(*x);
return f;
}
Sevo
--
Sevo Stille
sevo(at)ip23(dot)net
From | Date | Subject | |
---|---|---|---|
Next Message | Patrick Welche | 2000-02-02 11:56:13 | Re: [GENERAL] VACUUM ANALYSE |
Previous Message | Adriaan Joubert | 2000-02-02 07:25:10 | Re: [GENERAL] PL/pgSQL syntax/usage question |