how to call a C++ function from a C file when provided with only compiled code

A

ankitjain.bvcoe

I have an existing C++ library . Now i am another application using
this C++ lib.
The problem here is i want to call C++ fn. from C file .I cannot use
extern "C"declaration for that fn. because it is compiled using a g++.

tobeused.cc

writtenincpp(int i ,char c)
{
}

Since i have been provided with .o's and the header files ,i can change
only function prototypes and not function declaration.

What should i do ?

regards,
ankit
 
D

David Harmon

On 14 Sep 2006 22:08:07 -0700 in comp.lang.c++,
The problem here is i want to call C++ fn. from C file .I cannot use
extern "C"declaration for that fn. because it is compiled using a g++.

You need to write a "glue" function to go between. It should be
compiled as C++, with an extern "C" attribute so that it can be
called from your C code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top