Visual C++ function issues - Mailing list pgsql-hackers

From fishware@comcast.net
Subject Visual C++ function issues
Date
Msg-id 1171320544.465027.91010@a75g2000cwd.googlegroups.com
Whole thread Raw
Responses Re: Visual C++ function issues
List 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);
}



pgsql-hackers by date:

Previous
From: oliver rombaoa
Date:
Subject: automatic password for pg_dump to be used for a batch file in vb6
Next
From: Andrew Dunstan
Date:
Subject: Re: automatic password for pg_dump to be used for a batch file in vb6