Skip site navigation (1) Skip section navigation (2)

Re: [SQL] g++ not working for postgresql extension languages?

From: Stephen Jackson <Stephen(dot)Jackson(at)panting-deer(dot)org(dot)uk>
To: Lonnie Cumberland <lonnie_cumberland(at)yahoo(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: [SQL] g++ not working for postgresql extension languages?
Date: 2001-04-15 16:10:29
Message-ID: 3AD9C7F5.902BAE74@panting-deer.org.uk (view raw or flat)
Thread:
Lists: pgsql-interfacespgsql-sql
Lonnie,
                 
C++ uses "name mangling" to permit overloading of functions. Therefore
your function concat_text() ends up with a very different name. You can
probably get round this as follows:

#ifdef __cplusplus
extern "C" {
#endif
text *
concat_text(text *arg1, text *arg2);
#ifdef __cplusplus
}
#endif

This tells the C++ compiler that concat_text is a "C" name - so don't do
name mangling. This is a common technique for making C++ code callable
from C, although I haven't used it in the specific context you are
using.

Hope this helps,

Stephen Jackson
Home: Stephen(dot)Jackson(at)panting-deer(dot)org(dot)uk  www.panting-deer.org.uk
Work: Stephen(dot)Jackson(at)looksystems(dot)co(dot)uk    www.looksystems.co.uk

Lonnie Cumberland wrote:
> 
> Hi All again,
> 
> One more thing that I have tried.
> 
> If I now do a similar thing as in my previous message with the "funcs.c" file,
> but this time with the "funcs.cc" file then I can get:
> 

[snip]

> 
> trdata=# select concat_text('a','b');
> ERROR:  Can't find function concat_text in file /test/funcs.so
> trdata=#
> --------------------------------------------------------------------------
> 

[snip]

> 
> text *
> concat_text(text *arg1, text *arg2);
> 

[snip]

> so now I do not understand why the "gcc" version works and the "g++" version
> does not?
> 
> Just a side note in that I can easliy compile c++ the examples in the
> interfaces/libpq++ directory without any problems so that this is very strange
> to me.
> 
> I really need the "g++" version to work correctly as well?
> 
> Any ideas anyone?
> 
> Cheers
> Lonnie
>

In response to

Responses

pgsql-interfaces by date

Next:From: Lonnie CumberlandDate: 2001-04-15 18:20:11
Subject: Re: Re: [SQL] g++ not working for postgresql extension languages?
Previous:From: N@ta$Date: 2001-04-15 13:57:39
Subject: DBD and DBI::Pg

pgsql-sql by date

Next:From: Mitch VincentDate: 2001-04-15 16:40:00
Subject: Re: How to simulate MEMO data type?Thanks!
Previous:From: Julian ScarfeDate: 2001-04-15 10:43:01
Subject: RTREE on points

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group