Is there any software porting C++ to C?

J

James Kanze

[...]
I think I really need to c-code, because there are other libraries included
and this section is only part of the whole project. Although am not expert
in making projects.. so not sure. Maybe they could be compiled separately
and then link...
Usually calling C code from C++ is not too much of a problem. You do
compile the C modules separately, and then link the various bits. C++
provides:
extern "C" {...}
for just that purpose.

Calling C code from X++ is never a problem. Calling C++ code
from C isn't a problem either, provided 1) that the functions
you call are declared extern "C", and 2) that the main function
is written in C++ (and that you don't try to propagate any
exceptions through the C code, of course). In practice, the
second requirement can often be dropped: at least under Windows
and Linux (and Solaris, I'm pretty sure), main can be in C as
well, at least if your code is in a separate DLL. (I think the
main for both Python and the Java JVM is in C; their interfaces
are definitely in C; but there are lots of plugins for them
written in C++.)
 

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
474,141
Messages
2,570,817
Members
47,362
Latest member
ChandaWagn

Latest Threads

Top