Closure2fp
An example to illustrate how libffi cast a closure to a pointer to function.
Install / Use
/learn @wtdcode/Closure2fpREADME
closure2fp
An example to illustrate how libffi cast a closure to a pointer to function. Note that this only works on Linux x86_64.
Blog post link:
Sources
- closure.c closure.h: The closure lib to cast a closure to a raw function pointer.
- lib.c lib.h: The lib that provides API to register callback.
- main.c: The example that uses lib.h well-designed callback API.
- main.cpp: The example that uses lib.c well-designed callback API with a cpp wrapper.
- main_bad.c: The example that uses lib.h bad-designed callback API.
- main_bad.cpp: The example that uses lib.c bad-designed callback API with a cpp wrapper.
