Hacker News new | ask | show | jobs
by gtaena 608 days ago
How would you implement objects and inheritance in C without function casts? CPython certainly uses these casts.

dlysm() even relies on a (void *) cast that is not C standard compliant.

C is useless for certain applications with this "undefined behavior".

2 comments

That is the thing, people keep treating it as a portable macro assembler, when it stopped being so decades ago, and those folks haven't yet got the memo.
Use a generic function signature that takes in a `void*`. Inside the specialized function bodies, cast the void* to an `actual_type*`, then dereference.