[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc
Subject:    private (class)function symbol pruning
From:       Karl Vogel <karl.vogel () seagha ! com>
Date:       2004-07-18 12:38:33
Message-ID: 200407181438.33613.karl.vogel () seagha ! com
[Download RAW message or body]

I was wondering why G++ exports private class functions in shared libraries 
and also how to prevent G++ from doing this, without having to add 
__attribute__((visibility ("hidden"))) to every private function?!

ie.

=========== dummy.cpp
class Dummy {
        int value;
        int getpriv() const;

public:
        int getpub() const;
};
int Dummy::getpriv() const { return value; };
int Dummy::getpub() const { return value; };
===========

Compiled with G++ V3.4.0 like:
$ g++34 -shared -o dummy.so dummy.cpp

Shows that Dummy::getpriv() is also exported:

$ objdump -CT dummy.so|grep getpriv
00000504 g    DF .text  0000000a  Base        Dummy::getpriv() const

Using the following declaration:
        int getpriv() const  __attribute__((visibility ("hidden")));

prevents this from happening, but this seems like the wrong way of achieving 
this :)


Any hints, tips?
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic