F1

Endgame analysis using tablebases, EGTB generation, exchange, sharing, discussions, etc..
Post Reply
samar
Posts: 4
Joined: Mon Oct 29, 2007 1:27 pm

F1

Post by samar »

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
ath
Posts: 11
Joined: Sat Sep 15, 2007 6:56 am

Re: F1

Post by ath »

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.
samar
Posts: 4
Joined: Mon Oct 29, 2007 1:27 pm

Re: F1

Post by samar »

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
Post Reply