Why do I get an unrecognized token error when I use the _argt$ command in PolySpace Client for C/C++ 7.2 (R2010a)?
18 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2011 年 10 月 10 日
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?
採用された回答
MathWorks Support Team
2011 年 10 月 10 日
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 件のコメント
その他の回答 (1 件)
Anirban
2022 年 4 月 13 日
編集済み: Anirban
2022 年 4 月 14 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Troubleshoot Compilation Errors についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!