Is there a possibility to make replacements in preprocessor directives in Polyspace Code Prover R2019b?
3 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2020 年 2 月 19 日
回答済み: MathWorks Support Team
2020 年 2 月 19 日
I have a question concerning Macro definitions:
Is it possible to overwrite a special value which is defined by macro in order to have another verification behavior?
In the example below I want to manipulate CONSTANT_A and set it to 0 although it is set to 2 in the code. My goal is to force the verification to analyze also the else-path without touching the code.
#include <stdio.h>
#define CONSTANT_A (2)
#if (CONSTANT_A != 0)
#define MY_MACRO(_var) {_var = 0;}
#else
#define MY_MACRO(_var) {_var = 1;}
#endif
int main(void)
{
int a = 10;
int b = 20;
int res = a + b;
MY_MACRO(res);
return 0;
}
Is there a possibility?
採用された回答
MathWorks Support Team
2020 年 2 月 19 日
To change a MACRO within the C file before preprocessing, you can write files with corresponding regular expressions and specify them as described here:
The specified files (match.rxt and replace.txt) must be specified with their absolute paths.
The option itself is then entered in the configuration under "Other" in the Advanced Settings, in the form:
-regex-replace-rgx <path-to>\match.txt -regex-replace-fmt <path-to>\replace.txt
If you need more information about regular expressions, you can also refer to the MATLAB documentation here:
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!