Compilation problems with vc++

V

vasant63

Hi,

This is the compilation errors which I am getting when I compiling the
code with VC++ 6.0. The same code is getting compiled in Linux OS. I
would like to know how this compiler error can be eliminated?

d:\vasant\mysys\encoder\events.cpp(40) : error C2511: 'Register' :
overloaded member function 'void (enum EventType,void (__cdecl *)(enum
EventType,void *,void *),void *)' not found in 'EventManager'
d:\vasant\mysys\encoder\events.h(58) : see declaration of
'EventManager'
d:\vasant\mysys\encoder\events.cpp(54) : error C2511:
'CallbackRecord::CallbackRecord' : overloaded member function 'void
(enum EventType,void (__cdecl *)(enum EventType,void *,void *),void *)'
not found in 'CallbackRecord'
d:\vasant\mysys\encoder\events.h(68) : see declaration of
'CallbackRecord'

THE CONTENTS OF EVENTS.H

typedef void Callback (EventType, void*, void*);

class CallbackRecord;

class EventManager
{
public:
EventManager ();
void Register (EventType, Callback, void*);
void Trigger (EventType, void*);
private:
CallbackRecord* Callbacks[NumberEventTypes];
};

class CallbackRecord
{
public:
EventType type;
Callback* callback;
void* client_data;
CallbackRecord (EventType, Callback, void*);
};

THE CONTENTS OF EVENTS.CPP

void EventManager::Register (EventType t, Callback f, void* d)
{
CallbackRecord* crec = new CallbackRecord(t, f, d);
Callbacks[t] = crec;
}


CallbackRecord::CallbackRecord (EventType t, Callback c, void* d)
{
type = t;
callback = c;
client_data = d;
}

Thanks in advance.

Have a wonderful day.

With best wishes

Vasant
 
B

Bronek Kozicki

vasant63 said:
This is the compilation errors which I am getting when I compiling the
code with VC++ 6.0.

seems like compiler problem, but there is easy workaround. Explicitly use
pointer to function type in function parameters, that is replace Callback with
Callback* in following lines:
void Register (EventType, Callback, void*);
CallbackRecord (EventType, Callback, void*);
void EventManager::Register (EventType t, Callback f, void* d)
CallbackRecord::CallbackRecord (EventType t, Callback c, void* d)

You wouldn't have this problem if you used newer compiler. Regards


B.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top