Mixing C with C++ in CW7.1

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Mixing C with C++ in CW7.1

1,233件の閲覧回数
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

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 返信

659件の閲覧回数
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 件の賞賛
返信