IBM Support

Building of model by using Friend stereotype in Rational Rhapsody results in "not allowed outside of a class definition" error

Troubleshooting


Problem

Attempts to build a model by using the Friend stereotype in IBM Rational Rhapsody results in the error "not allowed outside of a class definition".

Symptom

Attempts to build a model having friend stereotype along with usage(Implementation) stereotype on the same dependency link in Rational Rhapsody results in the following error:

"C2255: 'friend' : not allowed outside of a class definition"

Image

Cause

Incorrect code generation. The friend statement is not being generated in the final code.

Resolving The Problem

To resolve this issue, create a separate dependency for the friend stereotype between the two classes to get the error free code by following the steps below:

  1. Develop a model in Rational Rhapsody with two classes(class_0 and class_1)

  2. Add dependency between the classes with stereotype as usage(Implementation)

  3. Add a separate dependency with friend stereotype

  4. Generate code for the model and build

[{"Product":{"code":"SSB2MU","label":"IBM Engineering Systems Design Rhapsody"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Rational Rhapsody Developer","Platform":[{"code":"PF033","label":"Windows"}],"Version":"7.5;7.5.0.1;7.5.1;7.5.1.1;7.5.2;7.5.2.1;7.5.3;7.5.3.1;7.5.3.2;7.6;7.6.0.1;7.6.1","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

swg21599964