IBM Support

error C2059: syntax error : 'bad suffix on number'

Troubleshooting


Problem

The Microsoft C/C++ compiler might throw this error, when the code contains an IBM Rational Test RealTime Code Review pragma. This technote proposes a workaround.

Symptom

The error message is as follows:

error C2059: syntax error : 'bad suffix on number'

Cause

See the following code.


#pragma attol crc_justify (Rule M1.1w, "Rule M1.1w : This rule is acceptable on the next line")

The Microsoft Visual C/C++ compiler reports the error on this line.



The Microsoft Visual C/C++ compiler interprets the first parameter of the crc_justify pragma, Rule M1.1w, as a number. However the suffix w is not an allowed suffix for a number. This is not a defect in the implementation of the pragmas. The ANSI C standard states, that compilers should ignore pragmas, that they do not understand.

Resolving The Problem

To workaround the problem you use the alternate name of the rule as the first parameter to the crc_justify pragma.

Open your project's confrule.xml file in a text editor. You can find the path to this file in the settings dialog box, section Code Review > Rule Configuration.
If you see the string default, open the file in the IBM Rational Test RealTime installation directory. For example:

C:\Program Files\Rational\TestRealTime\plugins\Common\lib\confrule.xml

In this file you see the following line near the beginning:

<rule name="CRC_10_11" label="Rule M1.1w" severity="2" repeat="0" errMsg="ANSI C warning: %name%" />

The name attribute gives the internal name for the rule. The label attribute gives the external name for the rule. You can use either the internal or the external name in thecrc_justify pragma.

Therefore to workaround this problem, you change your pragma to become:

#pragma attol crc_justify (CRC_10_11, "Rule M1.1w : This rule is acceptable on the next line")

[{"Product":{"code":"SSSHUF","label":"Rational Test RealTime"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Code Review for C","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"7.0;7.0.0.1;7.0.5;7.0.5.1;7.5","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Product Synonym

testrt;rtrt

Document Information

Modified date:
16 June 2018

UID

swg21391054