Visual C++ function issues

From: fishware(at)comcast(dot)net
To: pgsql-hackers(at)postgresql(dot)org
Subject: Visual C++ function issues
Date: 2007-02-12 22:49:04
Message-ID: 1171320544.465027.91010@a75g2000cwd.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I'm trying to implement the add_one sample in the PG docs using VC++
(for purposes of debugging). After some pain (had to add the
dllexport declspec below), I am able to get the CREATE FUNCTION
command to recognize the library and function. However, the function
blows up. I am able to attach the postgres.exe process and debug this
dll (I set a breakpoint on the int x = 1 line). I do get that far,
but then blow up trying to retrieve my argument on the following
line. Digging into this, I find that the fcinfo struct being passed
to me as an address of 0x000002 - that looks a little non-sensical to
me.

I am wondering if I've got the necessary project settings in Visual
Studio. How do we create a VC++ dll that is compatible with the gcc
PG build? Does anyone have a clue as to what these might be? I have
been doing a lot of digging and haven't seen anything directly
addressing this issue.

Many thanks....Eric

__declspec(dllexport)
Datum
add_one(PG_FUNCTION_ARGS)
{
int x = 1;
int32 arg = PG_GETARG_INT32(0);

PG_RETURN_INT32(arg + 1);
}

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gene 2007-02-12 22:53:06 Re: Acclerating INSERT/UPDATE using UPS
Previous Message Bruce Momjian 2007-02-12 22:29:48 Re: Acclerating INSERT/UPDATE using UPS