You have C source code.
Create a C++ source file containing the C source code, modified to adhere to the rules of C++.
The C language provides limited scoping and encapsulation of data and functions. It has no objects, but legacy systems often involve a large body of procedural code that could benefit from object-oriented refactorings. In order to apply object-oriented refactorings the code must first be ported to C++. Then the C++ code can be refactored from procedural code and data into objects. The objects can be further refactored with standard object-oriented refactorings.
C++ is syntactically compatible with C, but introduces new reserved keywords that are not present in the C language, such as
class and so-on. Because these additional keywords are reserved in C++ but not in C, you may need to apply Rename Function, Rename Field or Rename Variable refactorings in order to eliminate errors arising from compiling the source with a C++ compiler instead of a C compiler.
C++ is link compatible with C when external data and functions are declared with “C” linkage via the
extern "C" in the C++ code. Data and functions made available to C compilation unit from a C++ compilation unit must also be declared
extern "C" in order to be visible to the C code.
Read the rest of this entry »