MISRA Discussion Forums
Example for Rule8.10 (inline function) - 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.8 Declarations and defnitions (https://forum.misra.org.uk/forumdisplay.php?fid=163)
+---- Thread: Example for Rule8.10 (inline function) (/showthread.php?tid=964)



Example for Rule8.10 (inline function) - Wolfgang Gebauer - 20-06-2013

Hello,

I have a question regarding the Rule 8.10.
Usually in our code we implement inline functions in header files.
Therefore these inline functions are already visible in many modules.
How can these inline function be made static?
Is it necessary to implement these inline functions as static in header files?
example:

header_file.h
inline void function1(int a, int b)
{
...
return;
}

c_file1.c
include
void function3(void)
{
function1(a_param, b_param);
...
return;
}

Can somebody give me a solution?

Regards
Wolfgang


Re: Example for Rule8.10 (inline function) - misra-c - 01-07-2013

Hello Wolfgang

To comply with MISRA C:2012 Rule 8.10, the function should be declared with the static storage class, within the header file:

Code:
inline [i][b]static[/b][/i] void function1(int a, int b)
{
...
return;
}

Following inclusion of the header file in a source module, this declaration is visible, but only to the module(s) that have included the header file.