This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bizarre symbol names generated by g++


On Fri, 26 Sep 2003, Paul Harman wrote:

> Hi!
>
> These are probably very silly newbie questions, but I've been unable to get
> anything meaningful out of the mailing list's search engine...
>
> I'm having difficulties understanding the symbol names created by g++ when
> compiling C++ source code. I'm running g++ 3.2.1 on Solaris 2.8
>
> When I compile a simple function like this:
>
> 	bool render(node* aNode, struct gv__ContentItem &rendered);
>
> ... I don't get a symbol "render", I get this:
>
> 	_Z6renderP4nodeR15gv__ContentItem
>
> ...which is complicating my life a bit because I was hoping to use these
> functions in a dynamic library. dlsym() works okay if passed that label...
> but it's not a particularly pretty or understandable thing to look at!

Use extern "C" block and declare some initialization function inside it.
Then when you load your module, call this function and it will be able to
call all your object initialization machinery.

BTW: Please consider that calling C++ generated symbols directly is not
portable between various compilers and even between the same compiler, but
different version. (e.g. gcc2.95.x contra gcc3.x)

Cheers,

Karel
--
Karel Gardas                  kgardas@objectsecurity.com
ObjectSecurity Ltd.           http://www.objectsecurity.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]