|
![](/i/fill.gif) |
On 30 Jun 1999 06:30:06 -0400, Nieminen Mika wrote:
> This is true. Moreover, if you want to call a C-function from C++-code,
>you have to declare the function as: extern "C" foo bar(); (because the
>internal naming convention is different for C and C++).
>
> Btw, how do I call a C++ function from C?
Assuming you mean a global or static method that doesn't take reference
or class parameters, which is to say one that you can actually call from C,
just mark the prototypes as extern "C":
#ifdef __cplusplus
extern "C" {
#endif
int myfunc1( int, char );
.
.
.
#ifdef __cplusplus
}
#endif
You may have to write stubs to call static methods.
If you can't change the C++ code, you're still okay. You can write a C++
wrapper that consists entirely of stub "C" functions that call the name-
mangled C++ versions.
Post a reply to this message
|
![](/i/fill.gif) |