4 ms·
He proposes placing a value's vtable pointer in the memory word before the value's base address. Now you can pass the value around to APIs that expect, say, a C
by nielsbot 5y ago
He proposes placing a value's vtable pointer in the memory word before the value's base address. Now you can pass the value around to APIs that expect, say, a C-struct. But the vtable is "secretly" attached to it so you can call methods on it from your language implementation.
- scroot 5y agoI guess I just don't know C well enough. How can it be legal to put anything at a memory address before a given array? Does the compiler magically manage this? (Also if you know of any posts about this technique I would really appreciate it)