Mixing C/C++ and Func. Names

J

Jeremy Bishop

Hi,

I have a strange error... I am using a C lib with my C++ code. One of the C
lib functions requires a non-member callback function pointer defined by the
following typedef:

typedef void (*Callback)(void *userData, const char *name, const char
**atts);

I defined a function with this prototype, and marked its declaration with
extern "C". The problem is, when my callback function name begins with a
capitol letter, the compiler complains that the function pointer that I pass
cannot be converted to the expected typedef.... but, and here's the kicker,
when the function name begins with a lower-case letter, it works. Am I
going insane here? Any input on this would be helpful,



Thanks

Jeremy
 
C

Catalin Pitis

It is ok like this.

As I understood from your message, if you are saying something like:

SomeFunction( param1, Callback)

it should give you an error (assuming that SomeFunction is the function that
accepts a callback function pointer), because you specified a type as a
parameter, and not a pointer to a function.

If you say something like:

SomeFunction( param1, callback)

it should be ok, assuming that callback is an existing function with the
same signature as Callback typedef specifies.

I didn't see your code, but these are possibilities that I see.

Catalin
 

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

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
anuragag27

Latest Threads

Top