07
Dec
How can I create a C++ function that is callable by my C code?
Related Blog Items
- What do I need to know when mixing C and C++ code?
- How can I call a C function f(int,char,float) from my C++ code?
- Different signature problem with extern variables
- A simple window application
- const correctness
The C++ compiler must know that f(int,char,float) is to be called by a C compiler using the extern “C” construct:
// This is C++ code
// Declare f(int,char,float) using extern ”C”:
extern ”C” void f(int i, char c, float x);
…
// Define f(int,char,float) in some C++ module:
void f(int i, char c, float x)
{
…
}
The extern “C” line tells the compiler that the external information sent to the linker should use C calling conventions and name mangling (e.g., preceded by a single underscore). Since name overloading isn’t supported by C, you can’t make several overloaded functions simultaneously callable by a C program.
source:USENET
[tags]making a C callable function in c++[/tags]
Popularity: 5%
You need to log on to convert this article into PDF
Related Blog Items - What do I need to know when mixing C and C++ code?
- How can I call a C function f(int,char,float) from my C++ code?
- Different signature problem with extern variables
- A simple window application
- const correctness
Related Blog Items
- What do I need to know when mixing C and C++ code?
- How can I call a C function f(int,char,float) from my C++ code?
- Different signature problem with extern variables
- A simple window application
- const correctness
No Comments
No comments yet.