VS 2005 to VS 2012: do I need a cast now?

80 views Asked by At

OK, I have been searching for a solution to my error all day, so this is kind of my last hope.

I have ported this solution from VS 2005 to VS 2012 so that may make a difference if some settings or the compiler have changed.

I have a typedef which is then used in a struct in a template:

typedef bool (__cdecl *tBreakPointer)(const double&, const double&);

template <typename _T>
struct s_OptParameter
{
  tBreakPointer pAbortPointer;
};

These are the lines that give me the error (line in switch statement with '=' in it):

OptPara.nID = static_cast<unsigned int>(m_ParameterList->IndexOf(Item));
OptPara.nScale = Item->Scale;

switch (Item->Abort)
{
  case GeneticAbortType::Greater:
    OptPara.pAbortPointer = checkGreater;
    break;
}

checkGreater is defined as this:

bool checkGreater(const double& nAct, const double& nBreak)
{
  return (nAct > nBreak);
}

Now this is the error I get:

error C2440: '=' : cannot convert from 'bool (__stdcall *)(const double &,const double &)' to 'tBreakPointer'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast

All the usual answers don't seem to fit my problem as my code has been fine in VS 2005 and is not in VS 2012 - so any help or hints will be greatly appreciated.

0

There are 0 answers