Thread: weird function call

  1. #1
    Registered User
    Join Date
    Aug 2011

    weird function call

    Analyzing a source code, I've bumped into a strange function call. This function is defined with the following prototipe:

     static void nl_kaodv_callback(int sock);
    and the only call of this function nl_kaodv_callback is here:

     if (attach_callback_func(aodvnl.sock, nl_kaodv_callback) < 0) {
    	alog(LOG_ERR, 0, __FUNCTION__, "Could not attach callback.");
    as you can see the function nl_kaodv_callback is called WITHOUT any argument.

    What does it mean???

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    It is not called there. Its address is passed to the other function to call it when appropriate(as a callback...).

  3. #3
    Registered User
    Join Date
    Jan 2009
    Yup, you will have to look inside attach_callback_func to know what argument is passed to is.

  4. #4
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Often programs that deal with threads or concurrent programming will have a function call that passes a function name as an argument. attach_callback_func is going to call nl_kaodv_callback when it's ready.
    Quote Originally Posted by The Jargon File
    Microsoft Windows - A thirty-two bit extension and graphical shell to a sixteen-bit patch to an eight-bit operating system originally coded for a four-bit microprocessor which was written by a two-bit company that can't stand one bit of competition.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 07-08-2011, 01:16 PM
  2. function, function call, for loop
    By jackson6612 in forum C++ Programming
    Replies: 2
    Last Post: 05-03-2011, 04:03 PM
  3. Replies: 5
    Last Post: 10-17-2006, 08:54 AM
  4. Replies: 2
    Last Post: 06-21-2005, 02:41 PM
  5. function call for a average function
    By ricekingg in forum C++ Programming
    Replies: 1
    Last Post: 02-04-2002, 02:16 PM