Question

I am a beginner, so, please bear with me, if this sounds too trivial.When i searched over the net for this, i got results showing how to do it. My question is why we do it in the first place ?

Was it helpful?

Solution

This is specific to the Windows platform, when you're developping C++ DLLs.

You have to use the __declspec(dllexport) modifier in order for your class and its methods to appear on the exported symbol list for your DLL.

This way, executables using your DLL can instanciate and call methods in these classes.

However you have to make sure that the executable and the DLL are compiled by the same version of the same compiler, because C++ symbols are exported using a relatively complex name mangling encoding (you can see that using depends.exe), which format varies from one compiler to another.

OTHER TIPS

You don't need to export anything, unless you're creating a DLL. In that case, you can use the dllexport attribute as an alternative to the "old school" way of using .def files.

Technically you cannot export a class, only functions. However you can designate on a class level that all functions be exported.

Exporting a function means that that function can be called from outside of the current executable.

This is needed when you are writing a dll for example which is a separate entity.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top