필터 지우기
필터 지우기

I encounter a polyspace violation of MISRA C:2012 1.1 Too many macro definitions have. How to know which macros it is referring to ?

조회 수: 46 (최근 30일)
MISRA C:2012 1.1 (Required)
The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits.
Too many macro definitions have been found in this translation unit: 5034. The limit is 4095.
I encounter this violation with Polyspace bug finder. This violation is shown in CPUComm.c and Main.c . However, when i count the number of macros it is definitely a lot lower than 5034. Is there any other .h or .c it is referring to for the macros ? How do we know which files we need to search and how do we solve it ?
The main.c has a lot of header files. Do we need to also consider those to search for macros ?

채택된 답변

Shivang
Shivang 2023년 8월 28일
Hi Rohit,
I understand that Polyspace indicates a Standards violation regarding the number of macro definitions in two of your .C files.
Note that Polyspace counts not only macros defined in the .C file itself but also all macros defined in the header files. You've included several header files in your .C files. This is the reason the macro definition count in your .C files exceeds the limit specified in the Standard.
You can refer to the MISRA C:2012 1.1 documentation for more details: https://in.mathworks.com/help/bugfinder/ref/misrac2012rule1.1.html
  댓글 수: 1
Rohit
Rohit 2023년 8월 29일
Thank You Shivang,
I have cleared the violations using ifndef in every header files.
plcFunction.h ------
#ifndef PLCFUNCTION_H_
define PLCFUNCTION_H_
...............
#endif

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by