I have seen many projects where C++ calls C库. They all compile C库 using C编译器 into library, and then C++ code using the extern "C" methodincludeInterface, then write a class to encapsulate the interface you use, and finally link to library.
This will be easier and the correctness is guaranteed. If you change C to C++ source code, the workload will be too much and you will have to retest
Write a C++ class file to encapsulate the C code
I have seen many projects where
C++
callsC库
. They allcompile
C库
usingC编译器
intolibrary
,and then
C++
code using theextern "C"
methodinclude
Interface,then write a class to encapsulate the interface you use,
and finally link to
library
.This will be easier and the correctness is guaranteed. If you change
C
toC++
source code, the workload will be too much and you will have to retest