Click here to Skip to main content
15,885,763 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I would like to reduce the number of C++ class methods exported from a DLL that show up in the list of exported symbols with mangled names. This is an effort to reduce the size of C++ assemblies. Virtual functions implemented/overriden in a derived class can be accessed from a reference to it's base class. I was wondering if it's possible to selectively export/import all non-virtual constructors and methods, stripping away the virtual methods to reduce the number of exported symbols? So far, I get linker errors when attempting to import such classes. Exporting the entire class exports all virtual methods, thus bloating the assembly. It also exports the vpftable, which doesn't get exported otherwise, but this is the only method that works. I understand providing a factory method can achieve this from a reference to a base class, but those objects are strictly allocated on the heap and forgos stack allocation. Stack allocation us is a must for us because of performance reasons. From what I can tell this is not possible, but I'm hoping someone can shine a light my way and make me happy.
Posted

1 solution

Maybe it would be possible to export only some interfaces
(with needed functionality-aggregation(s) by (smart-)pointers) ? :)
C++
// Header to be "exported" :)

class CInsideClass; // public CInsiderBase, public ...
typedef std::auto_ptr<CInsideClass> CSafeInsider;

class (exp_decoration_here) IExpInterface
{
  CSafeInsider m_cInsider;
  
public:
  // Implement the constructor in the CPP-part to allocate the aggregation
  IExpInterface(..);

  // Define access to the desired Insider-functions here
  // ...
};
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900