Re: exporting classes in a DLL

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance





Nishant Sivakumar wrote:

The class declaration header file should look something like this :-

#ifdef EXPORTSCLASS
#define EXPORTCLASS_API __declspec(dllexport)
#else
#define EXPORTCLASS_API __declspec(dllimport)
#endif

class EXPORTCLASS_API CMyClass
{
public:
 //...
};

When you use this in the DLL project, define EXPORTSCLASS, but refrain from doing so in the EXE project where you call this dll.


Nishant, I tried this (exported a single method) and then run dumbin against my DLL. I find that the name of the method is mangled (as I had suspected).


Two questions:

If I declare a FAR PASCAL calling convention (i.e. declspec(export)) at the class level, do I get all the public methods exported "for free" or do I have to manually export every public method in the classes public interface?

2). If the names are mangled (ehich I suspect they will be because of the overloading etc I have in my code), can I still use the unmangled names of classes and methods in an application that links to the library?

tks

.



Relevant Pages

  • Re: exporting classes in a DLL
    ... When you use this in the DLL project, define EXPORTSCLASS, but refrain from doing so in the EXE project where you call this dll. ... If I declare a FAR PASCAL calling convention ) at the class level, do I get all the public methods exported "for free" or do I have to manually export every public method in the classes public interface? ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Can VBA be called by VB.NET and "vice-versa"???
    ... DLL, then call any public methods. ... Public Sub LinkInNetClass ... This reply is posted in the Newsgroup; ...
    (microsoft.public.office.developer.vba)
  • Re: DLL
    ... Create a Class Library project and create your functionas public methods ... Compile the project. ... instances of your .dll class and call its methods. ...
    (microsoft.public.dotnet.languages.vb)
  • RE: Exposing properties and methods
    ... public classes and public methods will be accessible ... Once your DLL is built, you need only add a reference from another ... > programs can "connect" to them at design time and then use them at run time? ...
    (microsoft.public.dotnet.languages.csharp)
  • XML comments not showing up in intellisense
    ... The xml comments I have on my public methods (using summary tag) only shows ... Once I compile the project ... what I need to do for the comments to show up when using the DLL in another ...
    (microsoft.public.dotnet.languages.csharp)