|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
We have a third party application coded in C++ which has hook for a
function that I need to implement. Is there a way such that I can implement it in C and give my code as a library. I cannot use the 'extern C' since the application is built without my header file. Example: ThirdParty.cpp extern void fun2(); fun1(){ .... fun2(); } My code is supposed to implement fun2() in C. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
sumaniitb@gmail.com wrote:
> We have a third party application coded in C++ which has hook for a > function that I need to implement. Is there a way such that I can > implement it in C and give my code as a library. I cannot use the > 'extern C' since the application is built without my header file. > > Example: > > ThirdParty.cpp > > extern void fun2(); > fun1(){ > ... > > fun2(); > > } > > My code is supposed to implement fun2() in C. Because when ThirdParty.cpp code is compiled it will see it as a C++ function declaration, it will want to call a C++ function so no, you can't compile fun2 in C (you can implement it in the C subset of C++ if you wish but I assume you mean compile it with a C compiler). The only thing I can think of is to have a translation layer, a fun2 in C++ that will call the actual fun2 implementation from C code. Something like: translation.cpp extern "C" void fun2_real(); void fun2() { fun2_real(); } ccode.c void fun2_real() { ... } -- Dizzy |
|
![]() |
| Outils de la discussion | |
|
|