gpt4 book ai didi

c - MISRA 2012 规则 8.10 静态内联

转载 作者:行者123 更新时间:2023-11-30 16:23:59 25 4
gpt4 key购买 nike

为什么 MISRA 建议使用static存储类声明内联函数?虽然关键字inline提示编译器将所有函数调用替换为实际的函数体,并且编译器可能会也可能不会执行它,但如何给出内部链接(static) 或函数的外部链接 (extern) 会影响编译器的内联操作吗?

最佳答案

MISRA C:2012 给出了规则 8.10 的基本原理:

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.

关于c - MISRA 2012 规则 8.10 静态内联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53743101/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com