a doubt in functions declared in a structure
From: nikhil bhargav (nikhilbhargav_nsit_at_indiatimes.com)
Date: 10/25/04
- Previous message: Mohd Hanafiah Abdullah: "Re: C to Java Byte Code"
- Next in thread: Jonathan Adams: "Re: a doubt in functions declared in a structure"
- Reply: Jonathan Adams: "Re: a doubt in functions declared in a structure"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: Mohd Hanafiah Abdullah: "Re: C to Java Byte Code"
- Next in thread: Jonathan Adams: "Re: a doubt in functions declared in a structure"
- Reply: Jonathan Adams: "Re: a doubt in functions declared in a structure"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|