Earl Purple wrote: > I think this has been addressed before but not for 2 years. > > I have a model whereby I dynamically load libraries with dlopen then > verify that they are the correct types with dynamic_cast. > > dynamic_cast seems to be failing though with gcc (I am using 3.2.1 > because that is the version we have here that also works with purify). > > Whilst I normally don't cast at all in my code, this is the one > occasion I do - I have built this type of model twice before, > successfully using Solaris compiler (which has all sorts of other > problems) and also on VC7 (obviously using LoadLibrary() etc) and it > worked then. > > It is vital I use dynamic_cast because reinterpret_cast would of course > lead to undefined behaviour if the type is a mismatch. > > And because the name of the symbol to be loaded is read from a > configuration file, there is no possibility of compile-time checks. > > Effectively, is it impossible to do object-broking in this manner using > gcc?
Actually I can follow this up by saying I do dynamic_cast twice and one of them works but the second one fails. The first one calls dynamic_cast on the actual object that is retrieved from dlsym, and that works. This particular object is a generic factory and creates another object. I then call dynamic_cast on the 2nd object to check it is the type we want and at that point it fails (when it shouldn't). _______________________________________________ help-gplusplus mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gplusplus
