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

推荐订阅源

Jina AI
Jina AI
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
Help Net Security
Help Net Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
GbyAI
GbyAI
博客园_首页
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LINUX DO - 最新话题
PCI Perspectives
PCI Perspectives
博客园 - 三生石上(FineUI控件)
V2EX - 技术
V2EX - 技术
Spread Privacy
Spread Privacy
T
Tor Project blog
量子位
阮一峰的网络日志
阮一峰的网络日志
S
SegmentFault 最新的问题
小众软件
小众软件
博客园 - 叶小钗
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Blog — PlanetScale
Blog — PlanetScale
H
Help Net Security
Y
Y Combinator Blog
N
News | PayPal Newsroom
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Tenable Blog
Scott Helme
Scott Helme
G
GRAHAM CLULEY
大猫的无限游戏
大猫的无限游戏
aimingoo的专栏
aimingoo的专栏
IT之家
IT之家
Schneier on Security
Schneier on Security
F
Fortinet All Blogs
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
博客园 - 司徒正美
Application and Cybersecurity Blog
Application and Cybersecurity Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Attack and Defense Labs
Attack and Defense Labs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The Last Watchdog
The Last Watchdog
L
LangChain Blog
C
Check Point Blog
Google Online Security Blog
Google Online Security Blog
V
Visual Studio Blog
Latest news
Latest news

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