Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: pointer functions, Macros, and errors, oh my  (Read 1005 times)

0 Members and 1 Guest are viewing this topic.
pointer functions, Macros, and errors, oh my
« on: April 02, 2010, 02:31:43 am »
  • Doesn't afraid of anything
  • *
  • Reputation: +42/-0
  • Offline Offline
  • Gender: Male
  • Posts: 7002
So I've got this little macro I wrote up to add some pointer functions into a database, the only problem is it isn't happy with it at all.  The Macro iss....

Code: [Select]
#define CREATE_ENT_LINK( index, className, entName ) \
static void * insert##className ( void ) \
{ \
return (new C##className); \
} \
static void className##Live ( void * address) \
{ \
C##className *temp = (C##className*)address; \
temp->live(); \
} \
static void className##Draw ( void * address ) \
{ \
C##className *temp = (C##className*)address; \
temp->Draw(); \
} \
class C##className##DataEntry \
{ \
public: \
C##className##DataEntry() \
{ \
HMDFunc::entData.addEntry( index, #entName, &insert##className, &className##Live, &className##Draw); \
} \
}; \
static C##className##DataEntry invoke;

Which I'm calling in a namespace down further in the program.  addEntry is defined as...

Code: [Select]
void CEntInfo::addEntry(int ID, std::string entName, entFactory factory, entCast casterLive, entCast casterDraw)
{
CEntClassCreation * temp = new CEntClassCreation(ID, entName, factory, casterLive, casterDraw);

if (!entClassDictionary.contains(temp))
entClassDictionary.append(temp);
}

Not too much to that.  And I have two typedefs for the pointer functions, which is where I think the problem is..

Code: [Select]
typedef void * (*entFactory)();
typedef void   (*entCast)();

The compile error, which I'm getting 4 times, reads..

Code: [Select]
error C2664: 'CEntInfo::addEntry' : cannot convert parameter 4 from 'void (__cdecl *)(void *)' to 'entCast'
Considering the fact that I have never worked with pointer functions before I haven't got a clue as to how to fix this.  I've poked around google, but can't find anything I can understand.  Halp?

EDIT: Nevermind, I got a work around.

« Last Edit: April 03, 2010, 02:03:45 pm by MG-Zero »
Logged



i love big weenies and i cannot lie
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.118 seconds with 36 queries.