Wednesday, June 24, 2009

Resource Management Across DLL Boundaries

Resource management across DLL boundaries in C++ is tricky. Here are the basic rules used in Boost.Extension:
  1. Anything allocated inside the DLL must be deallocated before the DLL is released. This means that if you pass a std::map into the DLL and modify it, you must delete (or at least clear()) the std::map before releasing the DLL.
  2. In order to use an interface across the DLL boundary, you basically have to guarantee that both the DLL and main executable were compiled with the same options - this is, for me, the primary weakness of C++ with DLLs.
  3. RTTI does not always function as expected across DLL boundaries. Check out the type_info classes to see how I deal with that.
  4. Always use virtual destructors for your interfaces - then you can safely delete them from the main binary or in the DLL.
It took a whole lot of trial and error to get this to work on different platforms.

Friday, August 1, 2008

Translation Bar

At least 50% of the visitors to this web site do not speak English as a first language. I have placed a Google Translation box on the left. Hopefully this will help make it easier to understand.

However, I realize that the translations it gives aren't very good - especially when it tries to translate source code. Don't misunderstand me - the Google software is quite impressive, but this is the type of text where a native speaker (who is also a programmer) is needed for a good translation.

If you would like to provide translations of any of the documentation content, I will post it here. The most important parts are the first two tutorials.

Download Options

There are a few different ways to install Boost.Extension and Boost.Reflection.

I've provided a download, to the left here, that includes both Boost.Extension, Boost.Reflection, and all Boost libraries needed for the examples and tests.

But, if you have Boost installed, you don't need all the other libraries, so feel free to just copy the boost/extension or boost/reflection directories to your Boost tree instead.

If you want to always stay up to date with the latest changes, you can also get the libraries directly from the Boost Sandbox using Subversion:

svn co http://svn.boost.org/svn/boost/sandbox/boost/reflection
svn co http://svn.boost.org/svn/boost/sandbox/boost/extension

Let me know if you have problems installing or compiling on any system.

Also, as a note, the libraries themselves are header-only.