views:

483

answers:

1

Is there a g++ equivalent to Visual Studio's __declspec(novtable) argument?

Basically, in a pure virtual base class the __declspec(novtable) argument can be used to suppress the creation of a vtable for the base class as well as vtable initialization/deinitialization code in the contstructor/destructor respectively. E.g.,

class __declspec(novtable) PureVirtualBaseClass
{
    public: 
       PureVirtualBaseClass(){}
       virtual ~PureVirtualBaseClass() = 0;
};

See Paul DiLascia's article for more info. Also see my related question.

+3  A: 

I don't think there is one -- if there was, it would be listed under the type attributes page of the GCC manual. GCC uses type attributes to add extra annotations to types (such as alignment and padding), but there is no type attribute equivalent to __declspc(novtable) listed there.

I also don't see any compiler flag in the man page relating to this optimization.

Adam Rosenfield