3 ms·
> ...the implementation does some _very_ sketchy things like forcibly casting pointers to unrelated types so they can be shoved through some multiply-recursive
by zoomablemind 3y ago
> ...the implementation does some _very_ sketchy things like forcibly casting pointers to unrelated types so they can be shoved through some multiply-recursive functions and then cast back to the correct type later.
I did not look into the code, however such casts can be a reasonable way to implement polymorphism in C.
Of course, having some common type field would be more robust, instead of blindly casting whatever pointer comes at input.
For example, such type could be defined as first field in the 'base' structure. Thus the cast into, say, `int` should yield a valid/expected type value, which would be checked in the called functions before casting into the expected type.