We have good code base in “c”. Now, we are moving to c++ for all new modules. I have a case to use few c++ classes in old c code base. Individually, both works i.e., c++ module and c module alone works and gives the desired o\p.
When, i mix them i.e., calling c++ classes in A.c, it throws tons of errors related to old code.
In our makefile.am, we earlier used to have an option cc=gcc, now we changed it to cc=g++ after it thrown few errors. The makefile.am with make at the end creates a lib, let us say libx.a. The makefile.am contains various earlier source files viz., A.c,x.c,y.c….
I fixed errors initially under A.c,x.c assuming that they are with new g++ compiler. Now,it started throwing errors under x.c, like this we have various source files.
Its very tedious to fix all of them. I believe iam missing some compiler flag options related to these errors. Now, majority of these errors are typecasting errors, where i converted them using static_cast etc. Apart from this, few misc errors. But, the code is a working code in c, its just mixing and changing makefile is throwing these errors.
Q:
1. How to get rid of those errors?
2. Is there any compiler flag which i need to use to continue working with minimal effort?
3. Is there some thing iam doing wrong in these process?
4. Any changes to makefile.am,you people suggest?
Any help on this is appreciated. If Q is not clear, please let me know.
Note: We run our app using autoreconf,configure and make.
Regards,
Santhosh
make will use either
$CCor$(CXX)depending on the extension of the files, and can use both at the same time. For example, files ending in*.cppare compiled with$(CXX), files ending with*.cwith$(CC). So you don’t have to setccorCCglobally tog++unless yourCcode is suitably modified to be compiled as C++.