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: RFC: Make dllimport/dllexport imply default visibility


On 6/15/07, Mark Mitchell <mark@codesourcery.com> wrote:
So, why not:

  struct S __attribute__((visibility("hidden")) {
    void f();
    void g() __attribute__((dllimport));
  };
  void S::f() { S::g(); };

In any case, in practice, ARM's RealView compiler accepts:

  struct __declspec(notshared) S {
    __declspec(dllimport) void f();
    void g();
  };

  void S::g() {
    f();
  }

And, there's a large body of code that uses this.

Because you missed typeinfo is also hidden (not just vtables).


So if you have (which is what you showed):

struct S __attribute__((visibility("hidden")) {
  void f();
  void g() __attribute__((dllimport));
};
void S::f() { S::g(); };

The typeinfo will be hidden and only in the shared library and not
exported (and if it is then that is a bug).

So in an user program you use typeid(S), you will get a link failure.
If f and g are switch around, you will then not get a link failure but
doing a "throw S();" with a catch on the outside, will cause the throw
to be caught by a try{ .... } catch (S &a) ...

Thanks,
Andrew Pinski


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