关于内联的问题 [英] question on inlining

查看:76
本文介绍了关于内联的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

没有内联关键字的函数永远不会内联吗?如果

不是真的,它是否内联?


ben

解决方案

< blockquote>

" ben" <是****** @ hotmail.com> skrev i en meddelelse

news:42 ********************** @ news.optusnet.com.au ...

没有内联关键字的函数永远不会被内联?如果
不是真的,它是否内联?



根据C ++标准,内联是由酌情决定的

编译器。因此,它可以内联未标记为内联的功能。并且

它可能不会内联标记为内联的函数。各种编译器允许您以这种或那种方式覆盖,例如:使用编译器开关或

使用特殊关键字,如__forceinline。

内联用户观点的目的是避免错误

多个定义。


/ Peter


inline关键字是一个提示,就像寄存器一样。编译器是免费的

完全忽略它。因此,如果没有内联关键字(或在类声明之外定义

)的函数可能会被内联,如果它满足某些未指定的内部启发式。编译器如何优化代码

依赖于实现。


ben写道:

没有内联关键字的函数永远不会被内联,这是真的吗?如果
不是真的,它是否内联?



编译器可以自由地内联它想要的任何函数。提供关键字内联

因为编译器一般都不够智能,用户可以帮助编译器这个

(但编译器仍然可以忽略建议)。


-

Ioannis Vranos

http://www23.brinkster.com/noicys


is it true that a function without an inline keyword never get inlined? If
not true when is it inlined or not?

ben

解决方案


"ben" <be******@hotmail.com> skrev i en meddelelse
news:42**********************@news.optusnet.com.au ...

is it true that a function without an inline keyword never get inlined? If
not true when is it inlined or not?

ben


According to the C++ standard, inlining is at the discretion of the
compiler. It might thus inline a function that is not marked as "inline" and
it might not inline a function marked as "inline". Various compilers allow
you to override that one way or another, e.g. by using compilerswitches or
by using special keywords such as __forceinline.
The purpose of inline for the user point of view is to avoid errors with
multiple definitions.

/Peter


The inline keyword is a hint, just like register. The compiler is free
to ignore it entirely. As such, functions without an inline keyword (or
defined outside of a class declaration) may be inlined if it meets some
unspecified internal heuristics. How a compiler optimizes code is
implementation-dependent.


ben wrote:

is it true that a function without an inline keyword never get inlined? If
not true when is it inlined or not?


A compiler is free to inline whatever function it wants. Keyword inline is provided
because compilers aren''t smart enough in general, and a user can aid the compiler to this
(but still the compiler is free to ignore the suggestion).

--
Ioannis Vranos

http://www23.brinkster.com/noicys


这篇关于关于内联的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆