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]

private (class)function symbol pruning


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?


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