From: | "Rodrigo Sakai" <rodrigo(dot)sakai(at)poli(dot)usp(dot)br> |
---|---|
To: | <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Passing parameters to a C function |
Date: | 2007-05-30 14:26:01 |
Message-ID: | 000001c7a2c6$75570510$9200a8c0@NOTEBOOKSAKAI |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello,
I have a question about passing parameters to a C function. Imagine the
example by PostgreSQL:
PG_FUNCTION_INFO_V1(complex_add);
Datum
complex_add(PG_FUNCTION_ARGS)
{
Complex *a = (Complex *) PG_GETARG_POINTER(0);
Complex *b = (Complex *) PG_GETARG_POINTER(1);
Complex *result;
result = (Complex *) palloc(sizeof(Complex));
result->x = a->x + b->x;
result->y = a->y + b->y;
PG_RETURN_POINTER(result);
}
So, in the same .C file I have to write another function that calls this
one, for example:
void
test_main()
{
Complex *a;
Complex *b;
a = complex_in("(4.01, 3.77 )");
printf("a = %s\n", complex_out(a));
b = complex_in("(1.0,2.0)");
printf("b = %s\n", complex_out(b));
printf("a + b = %s\n", complex_out(complex_add(a,b)));
}
But using version 1 calling convention it won't work! So, how can I pass the
'a' and 'b' variables in complex_add(?, ?)?
Thanks in advance!
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn van Oosterhout | 2007-05-30 14:41:20 | Re: Passing parameters to a C function |
Previous Message | Magnus Hagander | 2007-05-30 13:27:40 | Re: msvc, build and install with cygwin in the PATH |