From: Roy S. <roy...@ic...> - 2009-02-09 20:43:24
|
On Mon, 9 Feb 2009, Derek Gaston wrote: > Why can't you cast a void pointer to a class pointer dynamically? > Seems odd to me... so I'm probably doing something wrong. Apparently the compiler can't figure out where to find a vtable pointer unless it at least knows what the root base class is you're pointing to, and it can't figure out how to do a proper cast (at least in the context of multiple inheritance) without grabbing some kind of global offset information from there. You're handing PETSc a context and then getting handed it back in a callback function, right? Your only safe choice is probably to make sure that everything you hand PETSc in the same sort of context is a subclass of the same root, then static_cast to that root, then if you later find out that you both have and need a specific subclass you can libmesh_cast_ptr to that class from the root. --- Roy |