a doubt in functions declared in a structure

From: nikhil bhargav (nikhilbhargav_nsit_at_indiatimes.com)
Date: 10/25/04

  • Next message: gswork: "Re: should i also do C++"
    Date: 25 Oct 2004 00:13:14 -0700
    
    

    Hello all,

    I have a doubt in functions being directly used as an identifier in a
    C structure. For example, this code snippet is part of I2C controller
    intilization of mpc 860 processor. Here in structure i2c_state, the
    function i2c_ecb_t is declared as a field just like we declare any
    other type.

    How do we then call this function, Further is it possible to execute
    different functions by giving them deiffernet values?
     
    /*****************************************************************************/

    typedef void (*i2c_ecb_t)(int, int); /* error callback function */

    /* This structure keeps track of the bd and buffer space usage. */
    typedef struct i2c_state {
            int rx_idx; /* index to next free Rx BD */
            int tx_idx; /* index to next free Tx BD */
            void *rxbd; /* pointer to next free Rx BD */
            void *txbd; /* pointer to next free Tx BD */
            int tx_space; /* number of Tx bytes left */
            unsigned char *tx_buf; /* pointer to free Tx area */
            i2c_ecb_t err_cb; /* error callback function */
    } i2c_state_t;

    /*****************************************************************************/

    Any help would be highly appreciated.

    Cheers and thnks for ur time,

    nikhil


  • Next message: gswork: "Re: should i also do C++"

    Relevant Pages

    • Re: What instead of new/delete?
      ... Following is the code snippet from my application and now i dont wanna ... EXEC SQL BEGIN DECLARE SECTION; ... char *hv_creatorName; ...
      (microsoft.public.vc.mfc)
    • Re: What instead of new/delete?
      ... Following is the code snippet from my application and now i dont wanna ... EXEC SQL BEGIN DECLARE SECTION; ... char *hv_creatorName; ...
      (microsoft.public.vc.mfc)
    • Re: Why isnt my compiler warning me about this?
      ... >>> In the following code snippet, I declare the variable val as float in ... declare it. ... function scope object val hides the file scope object. ... The fact that is in a header is irrelevant. ...
      (comp.lang.c)
    • classes wrting/reading to binary file
      ... [code snippet appended at the end.) ... A class has a few string variables with not know length at design ... Now I declare lets say a 1000 of those classes and put them in a vector. ...
      (comp.lang.cpp)
    • Re: It actually happened today!! Vacuum failure in IMC.
      ... > the xpdr when we declare an emergency. ... So although the controller would see you no matter what code ...
      (rec.aviation.ifr)