Error reporting in a custom Qt-based plugin system: exceptions or getLastError?
-
In my project, the custom plugin system based on what Qt offers plays a crucial role, so error reporting when something goes wrong during the loading of a plugin is very important. In this system the plugin interfaces (the ones ending up in the
Q_INTERFACES
macro) usually have some method like this -virtual SomePluginClass* SomeInterface::loadSomePlugin ()
that spawns the actual plugin object. TheloadSomePlugin
is where a failure might happen.I am inclining towards exceptions as a personal preference, but ABI compatibility is what worries me in this case. The exceptions crossing the DLL boundaries in particular. Never touched the subject thoroughly, but as far as I understand throwing an exception from a DLL compiled with one compiler and catching it in a DLL compiled with another is very likely to end up in a disaster, and same could be true even for the case when different versions of the same compiler "collide".
On the other hand, since I am already knee deep in C++, why bother? Just tell the plugin authors to use the same compiler as I do? And it seems that the major compilers (MSVC, GCC and Clang) have been keeping the binary compatibility between the older and newer releases for a good while and have not broken it so far, so can I simply get away with telling the users to use at least the oldest binary compatible version?
And in the case of someone trying to load a plugin built with a different compiler, this is not going to work regardless of exceptions, is it? Exceptions in this case could be the least of my worries, as different compilers use different techniques for handling virtual functions (which are used abundantly in the project), name mangling and so on, so such attempt is doomed to fail anyway, right? So, for instance, nobody who is in their right mind will attempt to stick a plugin built with MinGW into a MSVC-based system?
Which brings me back to the main question: given that I have no control over the binary compatibility between compilers when using C++, I just choose what C++ features work best for me without trying to restrain myself, the feature being exceptions in this particular case, and just tell the potential plugin authors which compiler to use? Are my assumptions correct?
And in case you are wondering I am aware of the exception safety in Qt, so it has been taken care of. Also despite implying Windows in my post, I assume same principles apply to the Linux and Apple systems.