Clean pointer serialization in C

from blog Computer Graphics & Programming with Pekka Väänänen - 30fps.net, | ↗ original
Let’s say you’re programming in C and need to serialize a data structure to a storage format on disk. The storage format is not a perfect 1:1 representation of your internal data but for example a custom 3D model format of your game engine.