Search code examples
visual-studiodllvisual-studio-2005rtti

Is it allowed to link rtti enabled DLL within rtti disabled application?


I have a solution to build a DLL with run-time type information enabled in its project properties. This is the default (/GR) in Visual studio 2005. In our library we have a good few dynamic_casts, so I'm not able currently to build the DLL without run-time type information.

Now my customer is using development tools from Dassault Systèmes, which state they can not use Run-Time Type Information. It is disabled (/GR-) always.

The question is whether or not this is a problem?

I tried this situation with a small example in which a DLL is created with a bit of code doing dynamic casts. The DLL is built with RTTI enabled. A small application uses the DLL and especially the code with the dynamic_casts. This application is built RTTI disabled. It works fine. But with unpredictable behaviour anything can happen ...

I would like to tell my customer that mixing DLLs with some of them using RTTI and others not using RTTI is not a problem, but I couldn't find detailed information about it (using Google, MSDN, etc.). Does anyone know the answer to this problem?


Solution

  • Yes you can, but with very large of restrictions. Some of them:

    • don't pass any exception out of DLL,
    • don't use dynamic_cast on non-RTTI code,
    • You can get strange effect by comparing size of classes array from DLL sizeof(DllClass[10]) != sizeof(DllClass)*10
    • ...

    The most bright example of usage RTTI enabled DLL in non-RTTI environment - is inproc OLE server. You can develop DLL with any options, that is embedded into any application.