small functions defined in header files: inline or static?

后端 未结 3 2004
盖世英雄少女心
盖世英雄少女心 2021-01-07 19:17

I have a number of small functions which are defined in a .h file. It is a small project (now) and I want to avoid the pain of having declarations and definitio

3条回答
  •  既然无缘
    2021-01-07 19:44

    I think static inline is the way to go for functions you want to inline, and only static for those you don't want.

    static refers to visibility, but inline is ambiguous about visibility in the standard (C99). Anyway, it's not its purpose: inline is for inlining functions, thus it has a side-effect from a visibility point of view you might not want.

提交回复
热议问题