MISRA Discussion Forums
Rule8.9 applicability to const ? - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forum-4.html)
+--- Forum: MISRA C:2012 guidelines (https://forum.misra.org.uk/forum-21.html)
+---- Forum: 8.8 Declarations and defnitions (https://forum.misra.org.uk/forum-163.html)
+---- Thread: Rule8.9 applicability to const ? (/thread-1580.html)



Rule8.9 applicability to const ? - Soren_Kolbach_Hansen - 24-09-2021

Hello,

I have a question regarding rule 8.9.

We are currenly using static const instead of defines at the top of our files to manage implementation specific constants, however this is being flagged as a violation of rule8.9 if only used in one function, however as per the rationale of 8.9 this does not make all that much sense to us, is this really the intent of the rule?

Best regards

Soren


RE: Rule8.9 applicability to const ? - misra-c - 27-11-2021

Your code as described does violate rule 8.9 since a global object is only used within one function and could therefore be declared in that function.

However, the MISRA working group understands why you might want to list all your implementation specific constants in one place. In that case we suggest that you disapply this advisory rule for implementation specific constants and document the reason for doing it.