MISRA Discussion Forums
Note 9003: could define variable at block scope - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.9 Initialization (https://forum.misra.org.uk/forumdisplay.php?fid=164)
+---- Thread: Note 9003: could define variable at block scope (/showthread.php?tid=1285)



Note 9003: could define variable at block scope - PeterW - 12-10-2016

Hi,
In my code I have a static const array which is declared outside the block scope of the function where it’s used. Also it is only used by one function, so the Note 9003 is correct.
But the array is large and will ruin the overview of the function. So I want to suppress the warning using /*lint -e9003*/ before the array and /*lint +e9003*/ behind it.
But this has no effect. As I suppress the warning global it works, but this shall not be the way to do.
Any idea how to suppress the warning local for just one variable?


Re: Note 9003: could define variable at block scope - dg1980 - 12-10-2016

I don't think we should use this forum for tool specific questions:), better use http://www.gimpel.com/discussion.cfm?categoryid=0 next time.
To answer your question: use -esym(9003,Name_of_the_array) which suppresses 9003 for just that variable.


Re: Note 9003: could define variable at block scope - misra-c - 09-12-2016

The violation is correct. The MISRA-C working group is unable to comment on individual tools. We suggest that you contact your tool vendor.