Hi to all!

I never used Pointer Functions, and now i'm trying to use a C Pointer Function in Visual Studio 2005. But there's a problem... the pointer function isn't working properly... This kind of functions doesn't work in the same way in C and in C++?

My pointer function declaration in C is:

void (*FktFunction)( void * RegistFuncPtr, TOnDriverEvent eventcallback);

and the call definition is:

(*FktFunction)(TDriverLayer_RegisterDevice, TSMAData_OnNewEvent);

At this time, the function TDriverLayer_RegisterDevice isn't working at all.

The declaration of that function is:

int TDriverLayer_RegisterDevice(struct TDevice * newdev);

Anyone could help me with this?

Best regards.

Recommended Answers

All 2 Replies

The first parameter is a function pointer -- the prototype you declared on has a simple void object pointer void (*FktFunction)( void (* RegistFuncPtr)(struct TDevice * newdev), TOnDriverEvent eventcallback); I think you want something like the above. I didn't attempt to compile that, so not sure if it's exactly right or not.


>>(*FktFunction)(TDriverLayer_RegisterDevice, TSMAData_OnNewEvent);

You can simplify that somewhat like this: FktFunction(TDriverLayer_RegisterDevice, TSMAData_OnNewEvent);

Please, don't use this awkward combination of words as "Pointer Functions". No such beasts as "pointer functions" in C and C++. There are "pointer to function" types in both languages, there are correspondent values and variables. A pointer to function is a kind of POINTERS, not a kind of FUNCTIONS.

At this time, the function TDriverLayer_RegisterDevice isn't working at all.

Alas, I can't understand what's a problem: "isn't working at all" is not a proper case description. Can you explain the problem more clearly?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.