On Saturday, 19 March 2016 at 15:10:56 UTC, Alex wrote:
    void* funVoldemort(size_t my_size)

The term 'voldemort type' refers to a public type, just an unnamed one. What you have here is a pointer to a private type... and void* is something you often should avoid since the compiler doesn't help you with them. You can pass an entirely different object and the function would never know (until it crashes). It might look like a feature now, passing those size_t's around, but you'll probably find it buggy later...

The question is, how to write the accompanied function in the part, which should cast the pointer to the voldemort type?

You can't, the struct is too private to be seen. ff @ 20 and encapsulate it all in the same struct.

What I already thought about is: writing a union inside the struct, which is either my long or some other data. But this is in general not possible, as the "other data" could be together greater, then the long.

The compiler knows how to handle that, or you could use a wrapped pointer and ordinary private definitions so the outside doesn't pry too far.



Reply via email to