STAR   Computing Tutorials main page
How to Convert C code for C++ Compilation
  Maintained by Lee Barnby

This page outlines the steps to follow in converting your C code for compilation by a C++ compiler. The motivation for doing this is that compilation will then be stricter as explained in Valeri's email to starsoft-l. The list is a product of my experience in converting the code in pams/global/egr/track_propagator.c and I will use that as an example.

The steps are:

  1. Create a new directory and do a CVS checkout for your package.
  2. Work in stardev so that when it comes to compile and test your code the most up to date libraries are used, minimizing the chance of conflicts.
  3. Build your code in the usual way e.g. cons +pams/global. This is optional but by doing this you check that it does compile to start with which can save you work later on.
  4. Change the name of your file with C code in e.g. track_propagator.c becomes track_propagator.cc, following the naming conventions in our coding standards document
  5. Try to rebuild the code using cons -noR +pams/global. The option -noR instructs cons not to use the repository. If you omit this instead of compiling your new C++ file it will use the original C file from the repository.
  6. Now fix any errors that are reported.
  7. Once you have a version which compiles test your changes by running bfc. There are instructions on how to do this.
  8. Perform a CVS add of the new files and a CVS remove of the old .c files. CAUTION Once you do this you cannot re-introduce your original .c file to cvs in the normal way.
  9. Check-in your package as you would usually.