polyspace code prover: cosmic compiler issue

조회 수: 4 (최근 30일)
Karpakam Subramanian
Karpakam Subramanian 2020년 12월 3일
답변: Karpakam Subramanian 2020년 12월 7일
Hello All,
Polyspace does not recognize the "if" construct for cosmic compiler. Is there a workaround for this issue?
Error: this operator is not allowed in a preprocessing expression
# if (__XGATE_CHECK_VAR__ == 'X')
^
Code:
# if defined( MAKE_DEPEND )
/* The GNU compiler does not understand the following if-directive => make the dependency generator work... */
# else
# define __XGATE_CHECK_VAR__ __TRGT__[0]
# if (__XGATE_CHECK_VAR__ == 'X')
# else
# define V_MEMRAM1_FAR @gpage /* MCS12x part */
# if (V_COMPVERSION >= 407)
# define V_MEMRAM3_FAR @far /* MCS12x part */
# else
# define V_MEMRAM3_FAR /* MCS12x part */
# endif
# endif
# endif
#endif

답변 (2개)

Anirban
Anirban 2020년 12월 4일
편집: Anirban 2020년 12월 4일
Hi,
It is not the #if per se, but the [0] of __TRGT__[0] that is causing the problem. Following the standard, Polyspace does not support evaluations of expressions in preprocessor directives. Some compilers allow this but it is not supported in Polyspace yet.
There are several noninvasive ways to work around the issue, but all of them involving effectively replacing __TRGT__[0] with something else for the purposes of the analysis:
  • Assuming this code occurs in a header, you can make a copy of the header and replace the __TRGT__[0] with something else (depending on whether you want the #if or #else branch to be analyzed). You can place the copy in a separate folder and provide this folder as the first include folder in the project. This would cause the copy of the header to override the actual header during the analysis.
  • You can use the options -regex-replace-rgx and -regex-replace-fmt to make the replacement without modifying the actual source code.

Karpakam Subramanian
Karpakam Subramanian 2020년 12월 7일
Hello Anirban,
Thank you for the suggestion. Will try the solution provided , thanks.

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by