wcc386 vs wpp386 generated libraries

Does anyone know how to get around the name mangling of the wpp386 compiler?
I am trying to link to functions in a library compiled under wpp386 with a
program compiled under wcc386 (or vice versa). Can the wpp386 generated
functions be done with standard C calling conventions?

Any help would be appreciated.

Thanks
bcd

This has nothing to do whit wpp versus wcc. This is standard C C++ problem
:wink:

If you look at any of the standard header files (stdio.h) you will see they
have

extern “C” {

}

That tells the C++ compiler any protoypes or variable defined insided the {}
are
not to be mangle because they belong to C code.

Doing the other way around is ugly and not recommanded, much simpler (if
that option
is available to you) to turn to C into C++.

“Brian Delsey” <bdelsey@mindspring.com> wrote in message
news:8unc86$9i4$1@inn.qnx.com

Does anyone know how to get around the name mangling of the wpp386
compiler?
I am trying to link to functions in a library compiled under wpp386 with a
program compiled under wcc386 (or vice versa). Can the wpp386 generated
functions be done with standard C calling conventions?

Any help would be appreciated.

Thanks
bcd

Just wrap the prototypes for the C functions with extern C as described by Mario.
You can not call C++ member functions directly, you need to make C interface functions
in a C++ file that call those object functions. Ensure you wrap the interface function prototypes
with
extern “C” so that they can be linked to by the C modules. Do this by putting the prototypes in a
header files, and wrap the include for the header file with extern “C” when included in the .cpp
files, but not when included in the C file.

Example interface function in .cpp file

extern “C”
{
#include “defs.h” // Prototypes file, wrap with extern in C++ file, but not in C file
}

/* ---- Query: Account: Sales (BM CO CA) Get Report ---- */
BOOL get_report( WORD w_accnum, RPT_INFO *zp_report )
{
CSalesAcc op_acc; / object: Sales Account */

/* Clear Structure incase invalid Account */
memset( zp_report, NULL, sizeof(*zp_report) );

/* Check if Sales Account /
if ( ( op_acc = asfooop_acc_sales( w_accnum ) ) == NULL )
{
return ( FALSE );
}
/
Get Report */
op_acc->v_Get_Report( zp_report );
return ( TRUE );
}

As Mario said, it is much better to call C from C++ than the other way round. So just code all your
new files in .cpp files even if they are pure C, then you’ll save yourself alot of trouble - you can
call the C++ member functions directly from the C code in the .cpp files.
C++ also seems much more picky than C, so the C++ compiler will catch alot more potential problems
than the C compiler.

-Paul

Mario Charest <mcharest@zzinformatic.com> wrote in message news:8undkb$aj5$1@inn.qnx.com

This has nothing to do whit wpp versus wcc. This is standard C C++ problem
:wink:

If you look at any of the standard header files (stdio.h) you will see they
have

extern “C” {

}

That tells the C++ compiler any protoypes or variable defined insided the {}
are
not to be mangle because they belong to C code.

Doing the other way around is ugly and not recommanded, much simpler (if
that option
is available to you) to turn to C into C++.

“Brian Delsey” <> bdelsey@mindspring.com> > wrote in message
news:8unc86$9i4$> 1@inn.qnx.com> …
Does anyone know how to get around the name mangling of the wpp386
compiler?
I am trying to link to functions in a library compiled under wpp386 with a
program compiled under wcc386 (or vice versa). Can the wpp386 generated
functions be done with standard C calling conventions?

Any help would be appreciated.

Thanks
bcd
\