IBM Support

Rhapsody generated C code results in unexpected "enum" insertion

Technote (troubleshooting)


Attempts to generate C code with IBM Rational Rhapsody results in unexpected "enum" insertions.


You have an enumerated type named en_Bit_Faults defined in a file named file_0 under the Default package in a project.

You have another struct type named _st_Frame_Type in file_1 that has a field of this type.

When the file_0 property UseAsExternal is checked (to avoid code generation for it), the code for _st_Frame_Type in file_1 comes out as below:

struct _st_Frame_Type {
   int fault_count;  /*## attribute fault_count */
   enum en_Bit_Faults en_array_faults[10];  /*## attribute
en_array_faults */

The extra "enum" declaration in this case is unexpected. If file_0 property UseAsExternal is unchecked, code comes out properly without "enum" at the beginning.


When the enum is generated by Rhapsody (not external), the generated code looks like this:

typedef enum myEnum_t {
} myEnum;

The enum name has the "_t" suffix, and the typedef name does not have this suffix.

When you set the struct attribute to be of the enum type, the generated code actually uses the typedef name "myEnum"; however, when the enum is set to be external, Rhapsody does not assume
there is a typedef with that name, it actually assumes the external code looks like this:

enum myEnum {

Resolving the problem

Add in the model a typdef of the external enum, and use this typedef as the struct attribute type.

The generated code will be:

/*## type myEnum */

typedef enum myExternalEnum myEnum;

/*## type myStruct */

struct myStruct {

    myEnum attribute_0;      /*## attribute attribute_0 */  


Document information

More support for: Rational Rhapsody
Rational Rhapsody Developer

Software version: 7.5.3

Operating system(s): Windows

Reference #: 1499363

Modified date: 2012-11-13