Reverse Engineering C++ Code

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Projects and Code Engineering > Importing Source Code >

Reverse Engineering C++ Code

When it comes to reverse engineering, C++ projects are very big in size compared to Java, C#, or VB.NET projects. In general, it is recommended to use the reverse engineering function for small to mid-sized C++ projects. For big C++ projects, the import operation would take a very long time (for example, 15 minutes or more).

 

To import C++ projects into UModel, use the menu command Project | Import Source Project.

um_cpp_code_import

To import C++ projects authored in an IDE other than Visual Studio, use the menu command Project | Import Source Directory instead of Project | Import Source Project. For such projects, you will need to specify the preprocessor directives, include paths, and compiler settings from the import dialog box, see Code Import Options.

 

The include directories to be searched by the parser can be defined either at project level, from Code Import Options, or globally. To add include directories globally, set the environment variable UMODEL_CPP_INCLUDE to a list of directories, separated by ";". For example, you can add the include path "C:\example\include" as follows:

 

1.Open the Control Panel and start typing "environment variables" in the search box.
2.Click Edit the system environment variables.
3.Click Environment Variables.
4.Click New, and add a new variable with the name UMODEL_CPP_INCLUDE and the value C:\example\include.
5.Click OK to close all dialogs.
6.Restart UModel.

 

For C++ projects written with Visual Studio, the preprocessor directives and include paths are detected automatically from the .vcproj files. Microsoft Visual C++ compiler compatibility is supported starting with Visual Studio 6.0 up to Visual Studio 2015 (note this compatibility refers to the code dialect used in the source .cpp files; your Visual Studio project must be saved with Visual Studio 2010, 2012, 2013, or 2015 to qualify for import).

 

Note the following:

 

If UModel encounters an unknown data type during the import operation, the Messages window displays a warning, and the type appears in the model as int. This is unlike C# or Java, where unknown types are placed in the "Unknown Externals" package.
When you import C++ code into UModel, a built-in UModel profile for C++ is automatically added to the project. The profile includes the C++ basic (fundamental) data types and stereotypes required for code engineering, and is similar to profiles available for other languages.
Support for C++ attributes is limited. Only standard built-in attributes such as [[noreturn]], [[carries_dependency]], [[deprecated]] will be recognized. Custom (user-defined) attributes will be ignored.

 

Once the C++ code has been imported into UModel, you can make changes to it from the model, and then propagate the changes back to the code (round-trip engineering). As with other code engineering languages, the original source code implementation (for example, method bodies) remains unchanged after round-trip engineering. However, any data types or member names that you've changed in the model (for example, renamed classes) will be reflected in the code. For more information, see Example: Generate C++ Code and Synchronizing the Model and Source Code.


© 2019 Altova GmbH