|
|
|
|
Re: Convert c to cpp [message #1771338 is a reply to message #1770855] |
Thu, 24 August 2017 08:14 |
Eclipse User |
|
|
|
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.
Now fix any errors that are reported.
Generally you will find errors connected with the prototypes for any external
functions or subroutines. They may be missing or incomplete since C allows things
like extern void prop_circle_param_(); which gives and error at the line where you
call it such as "Error: Too many arguments in call to prop_circle_param_()".
The correct declaration for an externally defined function has this form:
extern "C" void prop_circle_param_(float *trk , float *xc, float *r);
If there are a number of these that will be used in more than one file they can be
collected in a header file. See for example pams/global/inc/global_prototypes.h.
If the external functions are defined in C then you can produce a header file using a
utility provided by Victor. Details are in his email.
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.
[Updated on: Thu, 24 August 2017 08:16] by Moderator Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04610 seconds