Обсуждение: Visual C++ function issues

Поиск
Список
Период
Сортировка

Visual C++ function issues

От
fishware@comcast.net
Дата:
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);
}



Re: Visual C++ function issues

От
Peter Eisentraut
Дата:
fishware@comcast.net wrote:
> 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.

Perhaps you forgot PG_FUNCTION_INFO_V1().

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/