Page 1 of 1

Type Comparison

Posted: Tue Sep 16, 2008 6:32 pm
by Lazarus404
Hey guys,

Okay, I'm finding it hard to locate an operator or function to use to compare types. I have a function that can acquire any type that extends a structure I've defined, but it's also possible that this function may acquire a type it isn't set to deal with, as the values are passed from a C dll. How do I compare types to check they are compatible, before extracting data?

Thanks,

Posted: Tue Sep 16, 2008 6:47 pm
by Trond
You can't do this. You must simply avoid passing in invalid data.

Posted: Wed Sep 17, 2008 1:11 pm
by tinman
If you have control of the base structure you could add a known identifier (either value or string) to the structure and make sure this matches with one you know how to handle.

Of course, that assumes the C DLL author won't be nasty enough to simply find out what the ID value is and copy it before stuffing it into their structure.

Got any more info on what you're trying to do?