determining if a void* points to a valid Object

Luís Marques luismarques+spam at gmail.com
Thu Aug 17 13:56:30 PDT 2006


Hello all,

I'm making a transition of a code base from C to D. I wish to alleviate 
the transition by making it gradual, but that requires being able to 
distinguish D Objects from the existing C structs, given a pointer.

Could you help me with this please?

1. You have a "void *ptr".
2. You have a struct NotDObject whose declaration you can control. (e.g. 
add fields and require that they possess certain values)

How do you determine with fairly good reliability if ptr points to an 
Object or to a NotDObject struct?

You are allowed to assume that DMD/GDC is used, and even a specific 
version of that compiler. I don't care much if it is a kludge (it's a 
temporary solution), but extra points if you can make it implementation 
independent.

Thanks a lot,
Luís Marques



More information about the Digitalmars-d mailing list