GCC:有关 GCC“优化”的问题和“内联”定义
我的问题如下:
1)如果我告诉 GCC 不要优化特定源文件中现有的代码,那么这将应用于从此文件调用的所有函数(这些函数可能驻留在不同的文件中)源文件)或仅适用于该文件中本地存在的函数/代码?也就是说,文件优化是否具有递归行为?
2)如果我将一个函数声明为内联(这样我就不会得到函数开销)并且该函数被声明到一个文件中,在该文件中我强制GCC不应用优化,那么如果我从另一个函数调用该函数源文件,我还会得到没有优化的效果吗?
任何帮助将不胜感激。
My questions are the following:
1) If I tell GCC not to optimise the code existing into a specific source file, then this will be applied to all the functions called from this file (which may reside into different source files) or only to the functions/code that exist locally in this file? That is, will the file optimisation have recursive behaviour or not?
2) If I declare a function as inline (so that I don't get the function overhead) and this function is declared into a file in which I force GCC to apply no optimisation, then if I call the function from another source file, will I still get the no optimisation effect?
Any help will be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于问题 2:
如果您在另一个源中包含带有内联函数的头文件,那么该函数将被内联,在内联之前对其进行编译是没有意义的。
To question number 2:
If you include a header vile with a inline function in another source, then the function will be inlined, it does not make sense to compile it before it has been inlined.
优化不是递归的 - 如果您不优化文件,那么只有该文件中的函数不会被优化。至于内联,该函数可以内联到其编译到的文件中,通常通过 #include 机制,如果这就是您所要求的(这还不清楚)。
Optimisation is not recursive - if you don't optimise a file, then its only the functions in that file which will not be optimised. As for inline, the function may be inlined in the file into which it is compiled, normally via the #include mechanism, if that is what you are asking (which is far from clear).