callback functions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • prashant.khade1623@gmail.com

    callback functions

    What are callback function ?

    how are they implemented and where they are useful ?

    what are the advantages of function pointer ?
  • Ian Collins

    #2
    Re: callback functions

    prashant.khade1 623@gmail.com wrote:
    What are callback function ?
    >
    how are they implemented and where they are useful ?
    >
    what are the advantages of function pointer ?
    Have you looked for the answers?

    --
    Ian Collins.

    Comment

    • prashant.khade1623@gmail.com

      #3
      Re: callback functions

      On Apr 11, 1:41 pm, Ian Collins <ian-n...@hotmail.co mwrote:
      prashant.khade1 ...@gmail.com wrote:
      What are callback function ?
      >
      how are they implemented and where they are useful ?
      >
      what are the advantages of function pointer ?
      >
      Have you looked for the answers?
      >
      --
      Ian Collins.
      I have googled.. but I couldnt find something which I can understand

      Comment

      • Chris Thomasson

        #4
        Re: callback functions

        <prashant.khade 1623@gmail.comw rote in message
        news:faf90c22-c153-4367-849b-d1610dc6606f@w4 g2000prd.google groups.com...
        On Apr 11, 1:41 pm, Ian Collins <ian-n...@hotmail.co mwrote:
        prashant.khade1 ...@gmail.com wrote:
        What are callback function ?
        how are they implemented and where they are useful ?
        what are the advantages of function pointer ?
        Have you looked for the answers?

        --
        Ian Collins.
        I have googled.. but I couldnt find something which I can understand
        Inform your professor immediately. Give him an example that you don't
        understand... See what his reaction is... Who knows, she/he may try to help
        you understand...

        Comment

        • Ian Collins

          #5
          Re: callback functions

          Richard Heathfield wrote:
          prashant.khade1 623@gmail.com said:
          >
          >What are callback function ?
          >
          Functions that you tell other functions about.
          >
          Doing homework now are we?

          --
          Ian Collins.

          Comment

          • Richard Heathfield

            #6
            Re: callback functions

            Ian Collins said:
            Richard Heathfield wrote:
            >prashant.khade1 623@gmail.com said:
            >>
            >>What are callback function ?
            >>
            >Functions that you tell other functions about.
            >>
            Doing homework now are we?
            Hmmm? Oh, er, maybe. Good point.




            I'M AWAKE!




            No, actually I might not bezzzzzzzzzzzzz zzzzzzz

            --
            Richard Heathfield <http://www.cpax.org.uk >
            Email: -http://www. +rjh@
            Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
            "Usenet is a strange place" - dmr 29 July 1999

            Comment

            • Jack Klein

              #7
              Re: callback functions

              On Fri, 11 Apr 2008 08:49:31 +0000, Richard Heathfield
              <rjh@see.sig.in validwrote in comp.lang.c:
              prashant.khade1 623@gmail.com said:
              >
              What are callback function ?
              >
              Functions that you tell other functions about.
              >
              how are they implemented
              >
              The function is implemented in the usual way - i.e. it's a function. The
              callback bit is done via a pointer to the function - you pass such a
              function pointer to the function that you want to call you back.
              What you describe above is the most common usage of callback
              functions, I suppose, but not the only one.

              In some cases the overhead of passing an extra function pointer object
              to every call is excessively burdensome. In other cases, it is not
              even always possible, for example in a kernel, although that takes us
              somewhat outside the realm of standard, portable code.

              In some cases I have provided packages which contain an external
              declaration like this:

              extern void (*Fatal_Error_H andler)(void);

              ....with the user documentation indicating that their program must
              define such a pointer and assign either NULL or a real function to put
              the system into a fail safe state and not actually return.

              This usage can save quite a bit of overhead if there are only one or a
              few specific callbacks needed, and they are only for extreme cases.

              --
              Jack Klein
              Home: http://JK-Technology.Com
              FAQs for
              comp.lang.c http://c-faq.com/
              comp.lang.c++ http://www.parashift.com/c++-faq-lite/
              alt.comp.lang.l earn.c-c++

              Comment

              • Richard Heathfield

                #8
                Re: callback functions

                Jack Klein said:

                <snip>
                >
                In some cases the overhead of passing an extra function pointer object
                to every call is excessively burdensome. In other cases, it is not
                even always possible, for example in a kernel, although that takes us
                somewhat outside the realm of standard, portable code.
                >
                In some cases I have provided packages which contain an external
                declaration like this:
                >
                extern void (*Fatal_Error_H andler)(void);
                >
                ...with the user documentation indicating that their program must
                define such a pointer and assign either NULL or a real function to put
                the system into a fail safe state and not actually return.
                Where every object in a container is likely to use the same callback (e.g.
                linked-list- or tree-walking), I have a pointer in the container itself
                rather than in any of its nodes, and set that up with a call to something
                like:

                int list_set_iterat or(list *lst, iterator *fn);

                Of course, the effect is the same.

                --
                Richard Heathfield <http://www.cpax.org.uk >
                Email: -http://www. +rjh@
                Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                "Usenet is a strange place" - dmr 29 July 1999

                Comment

                Working...