Mixing C with C++ in CW7.1

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Mixing C with C++ in CW7.1

1,234 Views
SVC2
Contributor II


Hi,

I have a whole project written in C, tested and running.

 

I would like to add any new file in CPP.

 

Is that possible without having to alter all existing files?

 

Is it possible to use


#ifdef __cplusplus
#pragma cplusplus on
#endif // __cplusplus

 

 

in the newly added CPP files without changing the project compiler settings (i.e., Force C++)?

 

Thanks,

SVC

Labels (1)
0 Kudos
Reply
1 Reply

660 Views
eGuy
Contributor IV

I don't know if there are other easy way or not.

 

What I know is: if you want to use functions defined in C from C++, in the C header file, you need to add some like these:

 

---------------------------------------------

 

#ifdef __cplusplus
    extern "C" {
#endif

extern float YOUR_C_FUNCTIONS( );

 

#ifdef __cplusplus
    }
#endif
 ------------------------------------------------

 

In addition, you need to link to the corresponding C++ libraries: like Cpp_4i_CF_RegABI_Runtime.a and 

C++_4i_CF_RegABI_MSL.a

 

 

In this way, you don't need to enable that "Force C++" selection

 

 

Regards,

 

Jeff

 

0 Kudos
Reply