- MC680X0 and I80X86 are not defined in the code provided to Polyspace. You are probably missing paths to some compiler headers in the Polyspace project.
- CPU_FAMILY is #define-d to MC680X0 in the code provided to Polyspace.
Polyspace Bug Finder ignores #if when checking macro values.
9 次查看(过去 30 天)
显示 更早的评论
I'm running a Polyspace Bug Finder analysis on some CPP code, with the following macro defined (via Configuration -> Macros):
CPU_FAMILY=I80X86
A header file from a library I'm using has the following:
#if CPU_FAMILY==MC680X0
#include <arch/mc68k/excMc68kLib.h>
#endif /* CPU_FAMILY==MC680X0 */
When analysing, I get the warning:
Warning: could not find include file "arch/Mc68kLIb.h"
It's correct that I don't have this header file, but the line should never have been parsed, due to the #if.
Please can someone tell me what I'm doing wrong?
Thanks.
Martin
0 个评论
采纳的回答
Anirban
2021-11-24
编辑:Anirban
2021-11-24
There could one of two things going on:
I explain the cases in detail below.
Case 1: MC680X0 and I80X86 are not defined
Let me give you an example. If you verify this code:
#if CPU_FAMILY==MC680X0
#include <arch/mc68k/excMc68kLib.h>
#endif
void main() {
int j = 1;
int k = j;
}
With the macro definition CPU_FAMILY=I80X86, you will see the replacement happening in the results, that is, you will see something like: #if I80X86==MC680X0. But the #include is not preprocessed out. This is because Code Prover has no knowledge of what I80X86 and MC680X0 are. #if does essentially integer comparisons, so unless I80X86 and MC680X0 are defined, Code Prover will not be able to do the comparison. You can check this by changing the code a bit to define those two macros. Like below:
#define MC680X0 1
#define I80X86 2
#if CPU_FAMILY==MC680X0
#include <arch/mc68k/excMc68kLib.h>
#endif
void main() {
int j = 1;
int k = j;
}
You will see that the #if comparison now works and the #include is preprocessed out.
Somewhere, in your compiler headers, the macros I80X86 and MC680X0 must be defined (which is how the #if-s will work). Somehow, in the way you set up the Polyspace project, those compiler headers did not get provided. So, for Polyspace, I80X86 and MC680X0 are two opaque things.
Case 2: CPU_FAMILY defined in headers
If CPU_FAMILY is defined in your headers to MC680X0, it will override your macro definition in the configuration. To check this, you can verify this code by setting CPU_FAMILY=I80X86:
#define MC680X0 1
#define I80X86 2
#define CPU_FAMILY MC680X0
#if CPU_FAMILY==MC680X0
#include <arch/mc68k/excMc68kLib.h>
#endif
void main() {
int j = 1;
int k = j;
}
You will see that the macro CPU_FAMILY takes the value defined in the code and not in the configuration.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bug Finder Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!