Re: Setting a C++ function as callback to a C Function!
On Jan 19, 7:55 pm, Sam <s...@email-scan.com> wrote:
Jay writes:
I have a C interface which takes a C function pointer as
input for setting callback. Now, I want to set a C++
function for the same.
I am getting a calling convention error.
Is it possible for me to do this?
Any pointers in that direction would be of great help.
Technically, this is allowed only if you declare your functio
with C linkage, inside an extern "C" {} block. However, in
practice, you can get away with using any static function.
Not if you use a good compiler. VC++ and g++ let you get away
with it, but the standard requires a diagnostic, and good C++
compilers issue one.
You cannot register a class member function as a callback from
C code.
Because, of course, they can't be ``extern "C"''. Both VC++ and
g++ do allow static class members, as well.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34