>I understand driver[0].Initialize(0); initialise the drivers by
>calling some function. jist I wanted to know what is that function
driver[0].Initialize(0) calls the Initialize function pointer of the 0th element of the driver array, which in this case is the function tpInit.
>Can anybody please tellme what is meaningof driver[0].Initialize(0); driver[0].GetNumPorts(0);
Function pointers are fun, no? Initialize and GetNumPorts are function pointers, when driver[0] is declared, it is also initialized with the address of function definitions that the function pointers are assigned to. So driver[0].Initialize(0); will call the tpInit function and driver[0].GetNumPorts(0); will call the tpGetNumPorts function.
Each inner brace of the array initialization list assigns the address of certain functions to the function pointers of each element, starting with zero. So the first three addresses (tpInit, tpShutDown, and tpGetNumPorts) are assigned to driver[0] and the next three are assigned to driver[1] if EPI is defined.
Code:
struct x_driver
{
int (*Initialize) (int port_offset);
int (*Shutdown) ();
int (*GetNumPorts) ();
};
struct x_driver driver[] = {
{ &tpInit, &tpShutdown, &tpGetNumPorts, },
{
#ifdef EPI
&epiInit, &epiShutdown, &piIGetNumPorts,
#endif
}
};
driver[0].Initialize(0);
driver[0].GetNumPorts(0);
p.s. This is C code and should be in the C board, not the C# board.
-Prelude