pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: TalGloz <glozmantal@gmail.com>
To: pgsql-general@postgresql.org
Subject: Re: PostgreSQL C Language Extension with C++ Code
Date: Sun, 12 Aug 2018 11:40:02 -0700 (MST)
Message-ID: <1534099202325-0.post@n3.nabble.com> (raw)
In-Reply-To: <31921.1534098408@sss.pgh.pa.us>
References: <1534093538827-0.post@n3.nabble.com>
	<CA+FnnTzH1gZ8o4a_WTD79kk7CNUzFu0NHUmbs03Gax0Su4Lgzw@mail.gmail.com>
	<1534097342417-0.post@n3.nabble.com>
	<31921.1534098408@sss.pgh.pa.us>

I did it with the macros

extern "C" {
Datum sum_of_numbers(PG_FUNCTION_ARGS);
PG_FUNCTION_INFO_V1(sum_of_numbers);
}

But now my compiler throws some other errors when running make:

g++ --std=c++17 -fPIC -Wall -Werror -g3 -O0 -o myfunc.o -c myfunc.cpp
-I/usr/pgsql-10/include/server -L"/usr/local/lib/libseal.a"
-I"/usr/local/include/seal" -I"/usr/local/include/cppcodec"
myfunc.cpp:29:10: error: conflicting declaration of C function ‘int64_t
sum_of_numbers()’
  int64_t sum_of_numbers(){
          ^~~~~~~~~~~~~~
In file included from /usr/pgsql-10/include/server/utils/array.h:64,
                 from /usr/pgsql-10/include/server/utils/acl.h:38,
                 from
/usr/pgsql-10/include/server/catalog/objectaddress.h:18,
                 from
/usr/pgsql-10/include/server/catalog/pg_publication.h:21,
                 from /usr/pgsql-10/include/server/utils/rel.h:21,
                 from myfunc.cpp:3:
myfunc.cpp:25:21: note: previous declaration ‘Datum
sum_of_numbers(FunctionCallInfo)’
 PG_FUNCTION_INFO_V1(sum_of_numbers);
                     ^~~~~~~~~~~~~~
/usr/pgsql-10/include/server/fmgr.h:374:14: note: in definition of macro
‘PG_FUNCTION_INFO_V1’
 extern Datum funcname(PG_FUNCTION_ARGS); \
              ^~~~~~~~
make: *** [Makefile:16: myfunc.o] Error 1

Why is it so hard to use C++ with PostgerSQL for a C extension? :)

Regards,
Tal



--
Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html




view thread (10+ messages)  latest in thread

Message-ID: <1534099202325-0.post@n3.nabble.com>
Permalink:  ../1534099202325-0.post@n3.nabble.com/
Also on:    postgresql.org/message-id/1534099202325-0.post@n3.nabble.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: glozmantal@gmail.com
  Subject: Re: PostgreSQL C Language Extension with C++ Code
  In-Reply-To: <1534099202325-0.post@n3.nabble.com>
  References: <1534093538827-0.post@n3.nabble.com> <CA+FnnTzH1gZ8o4a_WTD79kk7CNUzFu0NHUmbs03Gax0Su4Lgzw@mail.gmail.com> <1534097342417-0.post@n3.nabble.com> <31921.1534098408@sss.pgh.pa.us> <1534099202325-0.post@n3.nabble.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox