11-10-2019, 02:07 PM
The Amplification for rule 5.8 states
"An identifier used as an external identifier shall not be used for any other purpose in any name space or translation unit, even if it denotes an object with no linkage."
Appendix J of the MISRA C:2012 guidelines defines an external identifier as an "identifier with external linkage". In your example "int i" is assumed to be at file scope level and is therefore an external identifier. Therefore your example is a violation of rule 5.8.
"An identifier used as an external identifier shall not be used for any other purpose in any name space or translation unit, even if it denotes an object with no linkage."
Appendix J of the MISRA C:2012 guidelines defines an external identifier as an "identifier with external linkage". In your example "int i" is assumed to be at file scope level and is therefore an external identifier. Therefore your example is a violation of rule 5.8.
Posted by and on behalf of the MISRA C Working Group