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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 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