关于inline

canican 2010-09-13 09:06:41
1. inline作用域默认是文件域,为什么linux 代码中好多static inline 函数?加static是不是重复了
...全文
164 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
pengzhixi 2010-09-13
  • 打赏
  • 举报
回复
If all of the
file scope declarations for a function in a translation unit include the inline function
specifier without extern, then the definition in that translation unit is an inline
definition. An inline definition does not provide an external definition for the function,
and does not forbid an external definition in another translation unit. An inline definition
provides an alternative to an external definition, which a translator may use to implement
any call to the function in the same translation unit. It is unspecified whether a call to the
function uses the inline definition or the external definition
chenyu2202863 2010-09-13
  • 打赏
  • 举报
回复
static的free function表示但前的编译单元可见
job82824 2010-09-13
  • 打赏
  • 举报
回复
声明成static的成员函数可以被子线程直接访问。也可以使用::运算符外部访问。
pengzhixi 2010-09-13
  • 打赏
  • 举报
回复
inline函数还是可以被extern 声明外链性质的,加上static就不能声明为extern了。
冻结 2010-09-13
  • 打赏
  • 举报
回复
inline 和 static 一点屁关系没有。
各是各的用途。
冻结 2010-09-13
  • 打赏
  • 举报
回复
不是inline作用域默认是文件域!
是inline在编译的时候需要把声明和定义放在一个文件中。
不然找不到。
claudebell 2010-09-13
  • 打赏
  • 举报
回复
静态方法还可以保证该方法是类的方法,而不是类实例化的方法.

69,368

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧