04-12-2008, 09:18 AM
MISRA C Rule 8.10 seeks to reduce the number of externally visible objects and functions – this is generally accepted as a good design principle. The rule states that any objects or functions that do not require external linkage should be given internal linkage using the static storage class specifier.
In your example, which is a good design, even though the init function is called only once, it requires external visibility because it is called from a function that is defined in another module. Therefore, Rule 8.10 does not apply.
As an example of when Rule 8.10 would apply, suppose you had a function defined in the main module. Suppose that this function should only ever be called by functions that are also defined in the main module. This function should be given internal linkage.
In your example, which is a good design, even though the init function is called only once, it requires external visibility because it is called from a function that is defined in another module. Therefore, Rule 8.10 does not apply.
As an example of when Rule 8.10 would apply, suppose you had a function defined in the main module. Suppose that this function should only ever be called by functions that are also defined in the main module. This function should be given internal linkage.
Posted by and on behalf of the MISRA C Working Group