IBM Support

syntax error : missing ';' before identifier OR syntax error before ';'

Troubleshooting


Problem

Sometimes IBM Rational Rose RealTime will display an error from the compiler in the Build output window like: MSVC++ output: error C2146: syntax error : missing ';' before identifier '' GNU output: syntax error before ';'

Cause

The error is caused by an incompletely specified model. The model element being compiled references another model element, but has no dependency defined in the model for the referenced model element.

Resolving The Problem

Here is an (MSVC++ 6.0) example of the error output:

!> Compiling MyCapsule
MyCapsule.cpp
../src\MyCapsule.h(26) : error C2146: syntax error : missing ';' before identifier 'address'
../src\MyCapsule.h(26) : error C2501: 'Address' : missing storage-class or type specifiers
../src\MyCapsule.h(26) : error C2501: 'address' : missing storage-class or type specifiers
../src/MyCapsule.cpp(102) : error C2039: 'address' : is not a member of 'MyCapsule_Actor'
../src\MyCapsule.h(18) : see declaration of 'MyCapsule_Actor'
...

In the above example, MyCapsule has an attribute named address of type Address. However, MyCapsule has no dependency on the Address class, so the definition of Address is unavailable to the compiler.

There are a couple of ways to resolve this problem.

1) Manually supply the dependency in a class diagram.
2) Automatically create the dependency using Build > Add Class Dependencies...


Method one is the "usual" way of developing a UML model in Rose RealTime. The model is specified in a set of class diagrams showing the various model elements and the relationships between them. The classes are then added to a Component and an executable is built from a Component Instance. To manually add the dependency, open or create a Class Diagram containing MyCapsule and Address. Select the Dependency tool (- - - ->) from the tool palette and draw the dependency from MyCapsule to Address. Double click on the dependency to open its Specification and select the C++ tab. Set KindInHeader to "inclusion" and KindInImplementation to "none". (The defaults of "forward reference" and "inclusion" are not strong enough for an attribute.) Rebuild the model.


In method two, open the Build menu and select "Add class dependencies..." and click OK. Move the "Dependencies found:" to "New dependencies to be created:",click OK. Select MyCapsule in the browser or a class diagram and open its Specification, select the Relations tab and double click on the dependency on the class, Address. Set KindInHeader to "inclusion" and KindInImplementation to "none". Rebuild the model. (An advantage of this method is that it detects any other missing dependencies in the model in one operation.)


Note: The default settings for creating dependencies can be set from the Tools menu. Select Options, select the C++ tab, select Dependency from the Type drop down list and set KindInHeader to "inclusion" and KindInImplementation to "none". Warning: These settings will be appropriate for attributes but will result in unnecessary inclusions in the generated code for other types of dependencies. It is recommended that you do not use the stronger dependency settings as the default.

Note: If you do not change the KindInHeader and KindInImplementation (i.e. leave them set to "forward reference" and "inclusion") this will result in a compile time error of the form:

error C2079: 'address' uses undefined class 'Address'







[{"Product":{"code":"SSSHKL","label":"Rational Rose RealTime"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"--","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"2003.06.00","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Historical Number

20998

Document Information

More support for:
Rational Rose RealTime

Software version:
2003.06.00

Document number:
74705

Modified date:
16 June 2018

UID

swg21122367