惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threat Research - Cisco Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Know Your Adversary
Know Your Adversary
Scott Helme
Scott Helme
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Latest news
Latest news
雷峰网
雷峰网
T
Tor Project blog
T
Tenable Blog
Spread Privacy
Spread Privacy
博客园 - 叶小钗
D
DataBreaches.Net
美团技术团队
A
Arctic Wolf
Project Zero
Project Zero
L
Lohrmann on Cybersecurity
The GitHub Blog
The GitHub Blog
博客园 - 司徒正美
Security Latest
Security Latest
D
Docker
月光博客
月光博客
C
Cyber Attacks, Cyber Crime and Cyber Security
S
Secure Thoughts
T
Troy Hunt's Blog
U
Unit 42
WordPress大学
WordPress大学
I
Intezer
Forbes - Security
Forbes - Security
Microsoft Azure Blog
Microsoft Azure Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
SecWiki News
SecWiki News
罗磊的独立博客
The Last Watchdog
The Last Watchdog
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
aimingoo的专栏
aimingoo的专栏
B
Blog
博客园 - 【当耐特】
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security
S
Security @ Cisco Blogs
Microsoft Security Blog
Microsoft Security Blog
S
SegmentFault 最新的问题
The Cloudflare Blog
V
V2EX

博客园 - loop

brew 出现 git 错误的问题分析 xcode 编译器在各个arch下面默认宏 parallels无法启动之大乌龙-流水账版 关于结对敏捷开发 android openmax hardware decoder 整合记录 mac上parallel与virtualbox无法共存 git submodule 使用 VLC plugin加载代码分析 在parallel中安装archlinux + awesome 小米盒子试用 keepass管理密码 chrome同步书签cpu占用率过高问题解决 git对svn操作 mac上的ssh proxy客户端 --iSSH个人修改版 终于可以在家更新mplayer了 不要一个人吃饭 在archlinux中安装chrome 关于MP4 fileformat中 duration及timescale相关的几个地方 linux ramdom hung up
inline 小结
loop · 2013-04-16 · via 博客园 - loop

欢迎访问我的blog:http://blog.thinkinside.me

参考资料

http://www.cnblogs.com/cnmaizi/archive/2011/01/19/1939686.html

http://www.greenend.org.uk/rjk/tech/inline.html

http://gcc.gnu.org/onlinedocs/gcc/Inline.html#Inline

http://en.wikipedia.org/wiki/Inline_function

http://www.parashift.com/c++-faq-lite/inline-functions.html

http://www.cplusplus.com/forum/articles/20600/

C语言:

static inline

     gcc和c99标准的作用都一样。表示该函数具有static的特性(调用的c文件内有效)和inline特性(展开编译,需要的话会有独立汇编代码。无需进出栈操作)

extern inline

      gcc: 强制将函数设置为inline展开,所以这个函数地址是不存在的,不会有独立汇编代码。无法展开时(比如要取得函数地址)会去找外部的函数实现,如果在其他文件中未找到实现,会返回unresolved reference。

     c99: 会有独立的汇编代码。声明或实现有未声明inline,或者有声明了extern。

inline

   如果在a.c中实现了inline func_a() {…},那么:

       gcc: a.c中其他函数调用func_a是inline展开,其他文件b.c, c.c...中调用则是按照普通函数调用的模式,并非展开。func_a会有独立的汇编object

     c99:类似于gcc的extern inline。声明和实现都有inline,但没有extern。可以在本函数内实现一个外部函数的替代实现。不会有独立汇编代码,其他函数无法call到 

gcc

c99

static inline

如果需要会有独立object code

如果需要会有独立object code

inline

有独立object code

没有独立object code

extern inline

没有独立object code

有独立object code

C++:

declaration inline

     在class声明中实现的method默认是inline的

 class Fred {

public:

  void f(int i, char c){

...

}

};

definition inline

    在声明中不需要标明inline,在实现中标明

    如:

 class Fred {

public:

  void f(int i, char c);

};

inline

void Fred::f(int i, char c)

{

  ...

}

Microsoft VC:

       inline的关键字是__forceinline