MISRA 2012 rule 8.10 static inline

↘锁芯ラ 提交于 2019-12-20 02:59:13

问题


Why does MISRA recommends a inline function to be declared with static storage class? While the keyword inline is a hint to compiler to replace all function calls with actual function body and compiler may or may not perform it, how does giving a internal linkage (static) or external linkage (extern) to a function affect the inline operation by the compiler?


回答1:


MISRA C:2012 gives the rationale for rule 8.10 as:

Rationale

If an inline function is declared with external linkage but not defined in the same translation unit, the behaviour is undefined.

A call to an inline function declared with external linkage may call the external definition of the function, or it may use the inline definition. Although this should not affect the behaviour of the called function, it might affect execution timing and therefore have an impact on a real-time program.



来源:https://stackoverflow.com/questions/51714178/misra-2012-rule-8-10-static-inline

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!