Language Macros

Return to Introduction  Previous page  Next page

When reverse engineering a language such as C++, you might find pre-processor directives scattered throughout the code. This can make code management easier, but can hamper parsing of the underlying C++ language.

To help remedy this, you can include any number of macro definitions, which are ignored during the parsing phase of the reverse engineering. It is still preferable, if you have the facility, to pre-process the code using the appropriate compiler first; this way, complex macro definitions and defines are expanded out and can be readily parsed. If you don't have this facility, then this option provides a convenient substitute.

To Define a Macro

1.Select the Settings | Preprocessor Macros menu option. The Language Macros dialog displays.
2.Click on the Add New button.
3.Enter details for your macro.
4.Click on the OK button.

Macros Embedded within Declarations

Macros are sometimes used within the declaration of classes and operations, as in the following examples:

class __declspec Foo


       int __declspec Bar(int p);        


If declspec is defined as a C++ macro, as outlined above, the imported Class and operation contain a Tagged Value called DeclMacro1 with value __declspec. (Subsequent macros would be defined as DeclMacro2, DeclMacro3 and so on.) During forward engineering, these Tagged Values are used to regenerate the macros in code.

Defining Complex Macros

It is sometimes useful to define rules for complex macros that can span multiple lines. Enterprise Architect ignores the entire code section defined by the rule. Such macros can be defined in Enterprise Architect as in the following example:


where the ^ symbol represents the body of the macro.

Note : The spaces surrounding the ^ symbol are required.