Essentially, a callback function is a function supplied by the user
(thats you) and called from other code, which is typically a library.
Callbacks are nearly always used because a particular library demands
it, either because it is the smartest way to organise things (an example
is the comparison function passed with a qsort (3?) call, see the man
page for this (I dont have it handy here)), or because it is "natural"
for the flow of control of the program of the actual type (e.g. most
windowing system programs consists largerly of callbacks, handed over to
the windowing system and called at certain, most user-induced, events).
A callback is characterised by:
1) It is a perfectly normal userwritten C-function, with an argument
list conforming to that specified by the documentation for the library
facility, demanding a callback.
2) Its purpose is to undertake an highly specifiy task for the library,
either because it provides the flexibility necessary in the library
function, or accesses information not accessible to the library.
3) It is not (necessarily at least) called by user directly, it is
passed as an argument in a particular function call to the library in
question, thereby instructing the library to call it at certain
conditions.
Callbacks are heavily used in windowed applications. See e.g. the Gtk
tutorial at www.gtk.org for several examples (Gtk is a very popular
XWindows programming toolkit/framework?/widget set).
> ----------
> From: SookYoung Kim[SMTP:[EMAIL PROTECTED]]
> Reply To: SookYoung Kim
> Sent: 8. september 1998 09:18
> To: [EMAIL PROTECTED]
> Subject: callback function
>
> Hi, all..
>
> Is there someone that show me a sample program used callback
> functions?
>
> I understood callback function a little bit, but I don't know how i
> can
> write a callback functions..Please give me some clues..
>
> --
> Sook Young Kim
> E-mail: [EMAIL PROTECTED]
> [EMAIL PROTECTED]
>
>