Changing the order of struct or union members in generated code

In C and C++, when you create a struct or union and add members to it, the order of the members in the code generated by Rational® Rhapsody® is the order that is displayed on the Attributes tab of the features dialog. You can change the order using the arrow controls provided.

Procedure

  1. Open the features dialog for the struct or union.
  2. Select the attribute you want to move.
  3. Use the up/down arrows to move the attribute to a different location in the list.
  4. Click Apply or OK.

Results

The next time code is generated, the order of the members in the code will reflect the order that you specified.

Using alphabetic order in generated code

About this task

To have the struct or union members appear in alphabetic order in the code:

Procedure

Change the value of the CG::Type::AttributesAutoArrange property to True. This property can be set from the project level downward. So if you want the members of all structs and unions in the project to appear in alphabetic order in the code, change the value of this property at the project level.
Note: In C models this property only affects code generation for structs generated for Types in your model, not for structs generated to represent Classes in your model.

Feedback