Ron Natalie wrote:
"Thomas Matthews" <Th****************************@sbcglobal.net> wrote in message news:3F**************@sbcglobal.net...
Yes, you can pass a pointer to a non-member C++ function to a
C function. However, if the C function was compiled in a
separate translation unit with a C compiler you may have to
declare the function as 'extern "C";'.
You've lost me on that one. Just how do you get a C function compiled
into the same translation unit as a C++ function pointer?
Sorry, let me clarify my thoughts.
My understanding in this scenario is that there is a module,
lets say, old_func.c, which contains a non-member function:
void My_Function(void)
{
/* yada, yada, yada */
}
Let a C compiler (or a C++ compiler compiling in C mode)
translate this into old_func.o.
The function has the C language naming convention because
it was compiled using a C compiler.
If it was compiled using a C++ compiler, it _may_ have
a different {mangled} name than the C version.
Sooo, my point was that a function pointer in C++
may have an issue between when pointing to a function
compiled in C languge mode versus when it was
compiled in C++ mode. At the execution level, there
should be no difference. I believe only the Linker
{should there be one} would be the part that "chokes"
because of the naming conventions.
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq:
http://www.parashift.com/c++-faq-lite
C Faq:
http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book