ctypescastingdowncasterasure

Is type erasure concept exist in C-language?


I wonder if type erasing techniques are used anywhere in C language. What happens in C, when type casting is done? Does it use concepts similar to type erasure and down casting?

What are the main difference between type erasure and type casting?


Solution

  • Are you a Java developer?
    If yes you need to forget a LOT of things and learn another LOT.

    Down casting means inheritance. So this is not C.

    C can cast almost anything to anything (C assumes that you know what you are doing, contrary to Java, C# and others)

    Type erasure is a Java concept because JRE doesn't have generics at run-time, only raw-types.

    In C you have only binary code at run-time, just like in Assembly and that's all we need to have lightning-fast executables (remember that almost any compiler, framework or virtual machine is built in C or C++).

    In C there is no such thing of RTTI (Run-Time Type Information) and we don't need this because the aim of C is program directly over the metal.