weird function call

This is a discussion on weird function call within the C Programming forums, part of the General Programming Boards category; Analyzing a source code, I've bumped into a strange function call. This function is defined with the following prototipe: Code: ...

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    1

    weird function call

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

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

    Code:
     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
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,528
    It is not called there. Its address is passed to the other function to call it when appropriate(as a callback...).
    Manasij Mukherjee | gcc-4.9.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    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
    Posts
    352
    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, 02:16 PM
  2. function, function call, for loop
    By jackson6612 in forum C++ Programming
    Replies: 2
    Last Post: 05-03-2011, 05:03 PM
  3. Replies: 5
    Last Post: 10-17-2006, 09:54 AM
  4. Replies: 2
    Last Post: 06-21-2005, 03: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21