Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fovHe-0006EM-Km for pgsql-general@arkaria.postgresql.org; Sun, 12 Aug 2018 18:40:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fovHc-0005IK-4v for pgsql-general@arkaria.postgresql.org; Sun, 12 Aug 2018 18:40:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fovHb-0005ID-SS for pgsql-general@lists.postgresql.org; Sun, 12 Aug 2018 18:40:07 +0000 Received: from n3.nabble.com ([162.255.23.22]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fovHY-00021C-By for pgsql-general@postgresql.org; Sun, 12 Aug 2018 18:40:07 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id 50243E84D09A for ; Sun, 12 Aug 2018 11:40:02 -0700 (MST) Date: Sun, 12 Aug 2018 11:40:02 -0700 (MST) From: TalGloz To: pgsql-general@postgresql.org Message-ID: <1534099202325-0.post@n3.nabble.com> In-Reply-To: <31921.1534098408@sss.pgh.pa.us> References: <1534093538827-0.post@n3.nabble.com> <1534097342417-0.post@n3.nabble.com> <31921.1534098408@sss.pgh.pa.us> Subject: Re: PostgreSQL C Language Extension with C++ Code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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=3Dc++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 =E2=80=98int= 64_t sum_of_numbers()=E2=80=99 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 =E2=80=98Datum sum_of_numbers(FunctionCallInfo)=E2=80=99 PG_FUNCTION_INFO_V1(sum_of_numbers); ^~~~~~~~~~~~~~ /usr/pgsql-10/include/server/fmgr.h:374:14: note: in definition of macro =E2=80=98PG_FUNCTION_INFO_V1=E2=80=99 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.ht= ml