4 ms·
Yes, it works with structs of function pointers. And it works recursively. This works (this is slightly shorthand C, fill in the blanks yourself): struct
by pizlonator 4y ago
Yes, it works with structs of function pointers. And it works recursively.
This works (this is slightly shorthand C, fill in the blanks yourself):
struct config {
void (*foo)(things bar);
stuff (*bar)(int baz);
};
always_inline stuff doit(config c)
{
c.foo(whatever);
return c.bar(42);
}
always_inline void my_foo(...) { ... }
always_inline stuff my_bar(...) { ... }
stuff dostuff(void)
{
config c;
c.foo = my_foo;
c.bar = my_bar;
return doit(c);
}
This'll all get inlined and specialized to death.
- thrtythreeforty 4y agoGot it. That is definitely a cool insight. Thanks for sharing!