470,647 Members | 1,099 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,647 developers. It's quick & easy.

Using C++ With SPI?

I had been having good luck writing stored procs in C++ with Postgres.
But, today, I needed to include the SPI interface to help a trigger
along, aka

#include "executor/spi.h"

and this is completely ungrokable by GNU C++.

Am I stuck, or can I solve this problem (tried extern "C" {}, no go).

Thanks.

cwl
Nov 11 '05 #1
2 2947
Clay Luther <cl*****@cisco.com> writes:
I had been having good luck writing stored procs in C++ with Postgres.
But, today, I needed to include the SPI interface to help a trigger
along, aka

#include "executor/spi.h"

and this is completely ungrokable by GNU C++.

Am I stuck, or can I solve this problem (tried extern "C" {}, no go).


You'll definitely need 'extern "C" {}' around that include.

Why don't you try that again and actually post an error message so
people can try and help you?

-Doug

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 11 '05 #2
Pffft. I figured it was obvious.
#include "postgres.h"
#include "fmgr.h"
extern "C"
{
#include "executor/spi.h"
#include "commands/trigger.h"
};

int main(int argc, char* argv[])
{
return 0;
}

g++ -g -Wall -g -I/usr/include/pgsql/server -c practice.cpp
In file included from /usr/include/pgsql/server/executor/spi.h:22,
from practice.cpp:15:
/usr/include/pgsql/server/nodes/primnodes.h:568: parse error before
`using'
In file included from /usr/include/pgsql/server/nodes/relation.h:18,
from /usr/include/pgsql/server/executor/spi.h:23,
from practice.cpp:15:
/usr/include/pgsql/server/nodes/parsenodes.h:131: declaration does not
declare
anything
/usr/include/pgsql/server/nodes/parsenodes.h:131: parse error before
`typeid'
/usr/include/pgsql/server/nodes/parsenodes.h:184: parse error before
`typename'
/usr/include/pgsql/server/nodes/parsenodes.h:200: parse error before
`typename'
/usr/include/pgsql/server/nodes/parsenodes.h:314: parse error before
`typename'
/usr/include/pgsql/server/nodes/parsenodes.h:1146: parse error before
`typename
'
In file included from /usr/include/pgsql/server/utils/portal.h:23,
from /usr/include/pgsql/server/tcop/pquery.h:18,
from /usr/include/pgsql/server/executor/spi.h:28,
from practice.cpp:15:
/usr/include/pgsql/server/nodes/memnodes.h:44: parse error before
`delete'
In file included from /usr/include/pgsql/server/executor/spi.h:36,
from practice.cpp:15:
/usr/include/pgsql/server/utils/builtins.h:414: parse error before
`namespace'
make: *** [practice.o] Error 1


On Wed, 2003-07-02 at 15:17, Doug McNaught wrote:
Clay Luther <cl*****@cisco.com> writes:
I had been having good luck writing stored procs in C++ with

Postgres.
But, today, I needed to include the SPI interface to help a trigger
along, aka

#include "executor/spi.h"

and this is completely ungrokable by GNU C++.

Am I stuck, or can I solve this problem (tried extern "C" {}, no

go).

You'll definitely need 'extern "C" {}' around that include.

Why don't you try that again and actually post an error message so
people can try and help you?

-Doug


Nov 11 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Enos Meroka | last post: by
3 posts views Thread by Mike L | last post: by
3 posts views Thread by xzzy | last post: by
14 posts views Thread by pmud | last post: by
8 posts views Thread by acb | last post: by
reply views Thread by Metal2You | last post: by
reply views Thread by Eugene Anthony | last post: by
6 posts views Thread by =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.