J
Jianli Shen
following code:
some_file.c
void serverstream_metrics_register_obtain_bandwidth_cb(IntCallbackFunc
*cb) {
serverstream_metrics_obtain_bandwidth_cb = cb;
}
some_file.h
typedef int IntCallbackFunc(void); //what this means? IntCallbackFunc is a
type of int?
void serverstream_metrics_register_obtain_bandwidth_cb(IntCallbackFunc *cb);
handler_file.h
int obtain_latency_cb();
handler_file.c
int obtain_latency_cb() {
return (int)latency; // this value will finaly give to which parameter
in this program?
}
main_file.c
#include some_file.h
#include handler_file.h
main {
....
serverstream_metrics_register_obtain_bandwidth_cb(obtain_latency_cb);
....
}
Can anyone please explain why we use callback function in C/C++ , and how to
use it!
Thanks
some_file.c
void serverstream_metrics_register_obtain_bandwidth_cb(IntCallbackFunc
*cb) {
serverstream_metrics_obtain_bandwidth_cb = cb;
}
some_file.h
typedef int IntCallbackFunc(void); //what this means? IntCallbackFunc is a
type of int?
void serverstream_metrics_register_obtain_bandwidth_cb(IntCallbackFunc *cb);
handler_file.h
int obtain_latency_cb();
handler_file.c
int obtain_latency_cb() {
return (int)latency; // this value will finaly give to which parameter
in this program?
}
main_file.c
#include some_file.h
#include handler_file.h
main {
....
serverstream_metrics_register_obtain_bandwidth_cb(obtain_latency_cb);
....
}
Can anyone please explain why we use callback function in C/C++ , and how to
use it!
Thanks