Sb please explain this C/C++ instraction ?what does it mean?
ind = PfnIndCalcFun(iTb, side) (psqW, psqB, sqEnP, fInvert);
is the paranteses after function name castes the returend value ?
this code is in probe.c (crafty)
for whome that works with carfty:
PfnCalcIndex is a type used in carfty (ver 17.0 )that never defined. how is it possible????
tanx
F1
Re: F1
Without having seen the declaration of PfnIndCalcFun, I can only guess that it
is a function that returns a pointer to another function. Thus, you have two function calls:
the first one -- PfnIndCalcFun(iTb, side) -- returns the pointer to the second function
-- nameless here , but let's call it X -- which then is invoked as X(psqW, psqB, sqEnP, fInvert).
Expanded into two C lines it would be:
X = PfnIndCalcFun(iTb, side);
ind = X(psqW, psqB, sqEnP, fInvert);
or perhaps it should be 'ind = (*X)(...)' -- I don't remember these subtilities in C very well.
is a function that returns a pointer to another function. Thus, you have two function calls:
the first one -- PfnIndCalcFun(iTb, side) -- returns the pointer to the second function
-- nameless here , but let's call it X -- which then is invoked as X(psqW, psqB, sqEnP, fInvert).
Expanded into two C lines it would be:
X = PfnIndCalcFun(iTb, side);
ind = X(psqW, psqB, sqEnP, fInvert);
or perhaps it should be 'ind = (*X)(...)' -- I don't remember these subtilities in C very well.
Re: F1
Hi
here is the function:PfnIndCalc that uses a macro
macro declaration:
#define PfnIndCalc(iTb, side) (rgtbdDesc[iTb].m_rgpfnCalcIndex[side])
function definition:
extern "C" PfnCalcIndex PfnIndCalcFun(int iTb,color side)
{
return PfnIndCalc (iTb, side);
}
rgtbdDesc is an array ,type of it's elements is CTbDesc
typedef struct
{
.....
PfnCalcIndex m_rgpfnCalcIndex[2]; ....
}
CTbDesc;
as you see one member of CTbDesc structure is m_rgpfnCalcIndex that it's type is PfnCalcIndex ...
waiting for your help...
tanx
here is the function:PfnIndCalc that uses a macro
macro declaration:
#define PfnIndCalc(iTb, side) (rgtbdDesc[iTb].m_rgpfnCalcIndex[side])
function definition:
extern "C" PfnCalcIndex PfnIndCalcFun(int iTb,color side)
{
return PfnIndCalc (iTb, side);
}
rgtbdDesc is an array ,type of it's elements is CTbDesc
typedef struct
{
.....
PfnCalcIndex m_rgpfnCalcIndex[2]; ....
}
CTbDesc;
as you see one member of CTbDesc structure is m_rgpfnCalcIndex that it's type is PfnCalcIndex ...
waiting for your help...
tanx