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 1founf-0004iG-5q for pgsql-general@arkaria.postgresql.org; Sun, 12 Aug 2018 18:09:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1founa-0006iI-Vz for pgsql-general@arkaria.postgresql.org; Sun, 12 Aug 2018 18:09:06 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1founa-0006iB-K9 for pgsql-general@lists.postgresql.org; Sun, 12 Aug 2018 18:09:06 +0000 Received: from n3.nabble.com ([162.255.23.22]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1founX-0006LU-Jo for pgsql-general@postgresql.org; Sun, 12 Aug 2018 18:09:05 +0000 Received: from n3.nabble.com (localhost [127.0.0.1]) by n3.nabble.com (Postfix) with ESMTP id 66855E84BDB7 for ; Sun, 12 Aug 2018 11:09:02 -0700 (MST) Date: Sun, 12 Aug 2018 11:09:02 -0700 (MST) From: TalGloz To: pgsql-general@postgresql.org Message-ID: <1534097342417-0.post@n3.nabble.com> In-Reply-To: References: <1534093538827-0.post@n3.nabble.com> Subject: Re: PostgreSQL C Language Extension with C++ Code MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk OK now I have this code: 1: extern "C" { // The C header should go here 2: #include 3: #include 4: #include 5: #include 6: #include 7: #include 8: #include 9: #include 10: 11: PG_MODULE_MAGIC; 12: } 13: 14: // CPP header without extern "C" 15: #include 16: #include 17: #include 18: #include 19: #include // external compiled c++ library linked on running 'make' 20: 21: Datum sum_of_numbers(PG_FUNCTION_ARGS); 22: PG_FUNCTION_INFO_V1(sum_of_numbers); 33: 34: extern "C" { // CPP function 35: int64_t sum_of_numbers(){ 36: std::vector numbers {23, 445, 64}; 37: auto sum = 0; 38: for (auto &item : numbers){ 39: sum += item; 40: } 41: return sum; 42: } 43: } The error this time for PostgreSQL is: *ERROR: could not find function information for function "sum_of_numbers" HINT: SQL-callable functions need an accompanying PG_FUNCTION_INFO_V1(funcname). SQL state: 42883* Thanks, Tal -- Sent from: http://www.postgresql-archive.org/PostgreSQL-general-f1843780.html