Calling C++ external functions 
Author Message
 Calling C++ external functions

Hello....

In Visual Age, the ability to call external functions written in C++ is
limited due to the name mangling done by the compiler.  One is pretty much
limited to C functions.  Is this a prob in VW as well?  I am not overly
familiar with the mechanism and am planning on wrapping some widgets for
Linux but they are defined in C++ libs.

Thanks,

Chris



Wed, 18 Jun 1902 08:00:00 GMT  
 Calling C++ external functions
One approach, which I've used in C is to provide a C binding for  C++
code: (for those who're interested, it was to bind a simple X interface
written in C to the functionality of some C++ classes...)

It goes something like this:

//You are compiling a C++ file, so provide a C++ global function that
// does what you need
bogusCPlusPlusFunction(with, cpp, args)
{

Quote:
}

//Declare that the rest is just C code, but it can call the cpp function
//since they're part of the same name space, this makes the mangling
//internal to the file:
extern "C" {

//C function that will have a proper C binding
//but calls C++ code
bogusCPlusPlusWrapper(with, c, args)
{
  return bogusCPlusPlusFunction(with, c, args);

Quote:
}
};

> Hello....

> In Visual Age, the ability to call external functions written in C++ is
> limited due to the name mangling done by the compiler.  One is pretty much
> limited to C functions.  Is this a prob in VW as well?  I am not overly
> familiar with the mechanism and am planning on wrapping some widgets for
> Linux but they are defined in C++ libs.

> Thanks,

> Chris



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VC++ calling fortran function and fortran function calling a c++ function

2. C functions calling {C++/Ada/...} functions

3. External functions with Borland C++ 1.0

4. Calling an non-DLL external function

5. Can it call external functions?

6. function calls to external dll in 'routine's

7. ACCEPT LOOP / EXTERNAL DLL / FUNCTION CALL / GPF

8. Calling an external function (2003-03-11)

9. External function calls

10. Libraries Calling Their Own External Functions

11. calling external functions with a structure

12. Calling External DLL Functions

 

 
Powered by phpBB® Forum Software