31-03-2017, 12:06 PM
Thank you for your response, however, it appears that there has been a slight misunderstanding on what I was requesting.
MISRA C++ defines 'declaration' as the first introduction of a name in a translation unit and all subsequent 'declarations' in that translation unit are 'redeclarations'. Both MISRA versions catch the example of declarations in different translation units and I understand why that is a problem.
However, MISRA C goes further than MISRA C++, as at least my reading of the wording results in non-defining re-declarations as also being non-compliant:
In my opinion, this is unnecessarily restrictive, hence, I am requesting an example that shows why multiple non-defining (re)declarations in the same translation unit should be avoided.
MISRA C++ defines 'declaration' as the first introduction of a name in a translation unit and all subsequent 'declarations' in that translation unit are 'redeclarations'. Both MISRA versions catch the example of declarations in different translation units and I understand why that is a problem.
However, MISRA C goes further than MISRA C++, as at least my reading of the wording results in non-defining re-declarations as also being non-compliant:
Code:
/* file.h */
extern int i;
extern int i; // non-compliant
In my opinion, this is unnecessarily restrictive, hence, I am requesting an example that shows why multiple non-defining (re)declarations in the same translation unit should be avoided.
<t></t>