Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Appendix A - Windows Export and Import Declarations

On the Windows platform, special export declarations are required to make functions or classes in a .dll file accessible to the outside world. For normal usage of Boost.Extension, the only place this is required is in the one function that is exported from each .dll. The Hello World sample program illustrates how this is done using BOOST_EXTENSION_EXPORT.

For implementation inheritance across shared libraries, such as that in the Multiple Inheritance sample, each class that is not header-only that needs to be exported must have these declarations included. To make it more difficult, they must be different depending on whether the class is being imported into or exported from the current module. The Multiple Inheritance sample shows how this is done.

Warning

Now for a word of warning that many of you will ignore: In the great majority of cases, even if non-header-only implementation inheritance across shared libraries seems like a good idea, there is probably a better solution. Although it certainly has its uses, it can cause problems like the following:


PrevUpHomeNext