Why do I get an unrecognized token error when I use the _argt$ command in PolySpace Client for C/C++ 7.2 (R2010a)?
18 views (last 30 days)
Show older comments
MathWorks Support Team
on 10 Oct 2011
While compiling the code (obtained from IAR Compiler) in PolySpace Client for C/C++ 7.2 (R2010a), we are getting the following error:
"Error: unrecognized token".
The error seems to be because of the statement
#if _argt$(char)==1.
This maybe because ‘$’ is non ansi-c complaint? Could you please suggest a workaround for the above issue?
Accepted Answer
MathWorks Support Team
on 10 Oct 2011
The _argt$ command is specific to the IAR compiler, and is not ANSI C. This is the reason why Polyspace raised this error message.
This is used in limits.h (at least) of the IAR include files. In this file, we observe the following:
#if defined(__CHAR_MAX__)
#define CHAR_MAX __CHAR_MAX__
#define CHAR_MIN __CHAR_MIN__
... some code ...
#else /* !defined(__CHAR_MAX__) */
#if _argt$(char)==1 /* "char" = "unsigned" "char" */
#define CHAR_MAX 255
...rest of the code...
It can be observed that the line #if argt$(char)==1 is processed only if __CHAR_MAX_ is not defined.
Hence, the #if _argt$ function is used to notify if the 'char' type is signed or unsigned. If it is unsigned, CHAR_MAX is 255, and it is 127 in the other case.
To work around this issue, try the following steps:
1. Create a copy of limits.h
2. Rename it to avoid confusion. Let's say that the new name is limits_Polyspace.h
3. Edit limits_Polyspace.h and look for the line #if _argt$(char)==1.
4. Do the following change:
//#if _argt$(char)==1 /* "char" = "unsigned" "char" */
#if defined(_CHAR_IS_UNSIGNED)
...
Ensure that you have commented the line with argt$ and added a new one, based on the identifier _CHAR_IS_UNSIGNED.
5. Use the option -include with the file limits_Polyspace.h. By doing so, this version of limits.h will be used instead of the one of the IAR compiler.
6. Define the flag _CHAR_IS_UNSIGNED in your PolySpace project if the 'char' type is unsigned, and do not if the 'char' type is signed.
0 Comments
More Answers (1)
Anirban
on 13 Apr 2022
Edited: Anirban
on 14 Apr 2022
The compiler in IAR Embedded Workbench is directly supported in Polyspace since R2018a. You will not have these errors from that release onwards and not have to work around them manually.
See:
The message:
"Error: unrecognized token"
mostly appears in cases where a compiler is not directly supported and you have to pick the default compiler and then manually set up your analysis configuration. For reasons behind the error and workarounds, see Fix Polyspace Compilation Errors About Undefined Identifiers.
0 Comments
See Also
Categories
Find more on Troubleshoot Compilation Errors in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!