gpt4 book ai didi

c - C 和内联函数中的独立目标代码

转载 作者:行者123 更新时间:2023-12-01 21:53:04 24 4
gpt4 key购买 nike

我正在阅读来自 Inline Functions In C内联 函数当我遇到这条线时:

Sometimes it is necessary for the compiler to emit a stand-alone copy of the object code for a function even though it is an inline function - for instance if it is necessary to take the address of the function, or if it can't be inlined in some particular context, or (perhaps) if optimization has been turned off. (And of course, if you use a compiler that doesn't understand inline, you'll need a stand-alone copy of the object code so that all the calls actually work at all.)

我完全不知道它想说什么,有人可以专门解释一下什么是独立目标代码吗?

最佳答案

“目标代码”一般是指编译器的输出交给链接器,作为生成机器码之前的中间步骤。

文中所说的是,如果您出于某种原因获取了函数的地址,例如使用指向它的函数指针,则无法内联该函数。因为内联函数没有可以通过函数指针调用的地址。内联函数只是与调用代码链接在一起,实际上没有进行任何函数调用。

关于c - C 和内联函数中的独立目标代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58879678/

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