S
Spiros Bousbouras
I'm writing a library where on error the library functions are supposed
to call a function with prototype
unsigned long error_handler(unsigned long , unsigned long)
which should be supplied by the user. The question is what should the
library header contain to make it as easy as possible for the user to
declare or define such functions or pointers to such functions or casts
to pointers to such functions etc. and that if the prototype for an
error handler changes the user will have to do as few modifications as
possible to his source.
At present the header contains
typedef unsigned long (*error_handler_type)(unsigned long , unsigned long)
#define error_handler_def(foo_name , var1 , var2) \
unsigned long foo_name(unsigned long var_name1 , \
unsigned long var_name2)
so for a declaration the user can do
error_handler_type my_error_handler ;
and for a definition
error_handler_def(my_error_handler , foo_id , err_id) {
...code...
}
Is there a better way ?
to call a function with prototype
unsigned long error_handler(unsigned long , unsigned long)
which should be supplied by the user. The question is what should the
library header contain to make it as easy as possible for the user to
declare or define such functions or pointers to such functions or casts
to pointers to such functions etc. and that if the prototype for an
error handler changes the user will have to do as few modifications as
possible to his source.
At present the header contains
typedef unsigned long (*error_handler_type)(unsigned long , unsigned long)
#define error_handler_def(foo_name , var1 , var2) \
unsigned long foo_name(unsigned long var_name1 , \
unsigned long var_name2)
so for a declaration the user can do
error_handler_type my_error_handler ;
and for a definition
error_handler_def(my_error_handler , foo_id , err_id) {
...code...
}
Is there a better way ?