2 ms·
It's not necessarily just ugly but plain idiomatic C. It's just C: a function pointer + userdata pointer. All hooks, callbacks, etc. use this approach because
by yason 16y ago
It's not necessarily just ugly but plain idiomatic C. It's just C: a function pointer + userdata pointer.
All hooks, callbacks, etc. use this approach because that's what a closure is on a low enough level. And in C it looks like void()(void userdata).
- timrobinson 16y agoMy "ugly" comment comes from spending my career programming against APIs like this :) typedef BOOL (* WNDENUMPROC) (HWND, LPARAM); BOOL WINAPI EnumWindows(WNDENUMPROC lpEnumFunc, LPARAM lParam);