A
Alfonso Morra
I have come accross some code where function pointers are being cast
from one type to another (admittedly, they all have the same return
type). eg. you may have func ptrs declr as ff:
typedef void (*vfptr)(void) ;
typedef void (*vfptr_i)(int) ;
typedef void (*vfptr_ii)(int, int ) ;
typedef void (*vfptr_iis)(int, int, char*) ;
the first declaration is used like a kind of base class functor in the
sense that sometimes, the other classes are cast "down" to it. In these
cases, the func args are determined at run time - typically, retrieved
from global variables etc.
This seems quite reckless. I have never seen anything like it before.
Has anyone come accros something like this before?
from one type to another (admittedly, they all have the same return
type). eg. you may have func ptrs declr as ff:
typedef void (*vfptr)(void) ;
typedef void (*vfptr_i)(int) ;
typedef void (*vfptr_ii)(int, int ) ;
typedef void (*vfptr_iis)(int, int, char*) ;
the first declaration is used like a kind of base class functor in the
sense that sometimes, the other classes are cast "down" to it. In these
cases, the func args are determined at run time - typically, retrieved
from global variables etc.
This seems quite reckless. I have never seen anything like it before.
Has anyone come accros something like this before?