【问题标题】:Inline Static function and static variables内联静态函数和静态变量
【发布时间】:2013-06-13 04:55:58
【问题描述】:

使静态函数内联有什么用?而不是在两个文件中使用相同的功能;他们还有其他使用静态函数吗?

inline static int func(int a)
{    
    static int b;     
    printf("Hello World !\n");    
    return b;
}

【问题讨论】:

    标签: static-members inline-functions static-functions


    【解决方案1】:

    inline 始终只是向编译器提示您希望函数内联而不是正常调用。不过没必要关注。

    static 使您的函数仅对当前翻译单元可用。例如,这对于编写您不想导出其功能的辅助函数很有用。或者,正如您所说,如果您出于某种原因必须在两个翻译单元中使用相同的函数名称。

    【讨论】:

      猜你喜欢
      • 2016-04-27
      • 2010-09-16
      • 1970-01-01
      • 2016-07-26
      • 2017-09-02
      • 2016-08-30
      • 1970-01-01
      • 2013-11-04
      • 1970-01-01
      相关资源
      最近更新 更多