On Tuesday, April 3, 2012 at 3:38:08 PM UTC-5, Benoit Jacob wrote:
> Hello,
> 
> Short version: "inline" alone is enough to take care of multiple
> function definitions. Next time you're about to write "static inline"
> in a header file, seriously consider doing "inline" instead.
> 
> Long version:
> 
> This command,
> 
>   $ find mozilla-central -name '*.h' | xargs grep -n 'static inline'
> 
> finds 1851 matches here.
> 
> The "inline" keyword does two things that I know of:
>  1) it suggests inlining, and
>  2) it allows multiple definitions of a function, regardless of
> whether inlining happens.
> 
> That second thing means that in most cases, defining a "static inline"
> function in a header is useless, and just "inline" is what is really
> wanted in most cases.
> 
> The "static" keyword in "static inline" is harmful in the situation
> where a "static inline" function gets included and compiled in N
> different files and does not get inlined. In this situation, one would
> typically want the N copies of this function to get merged into one,
> to avoid code bloat. But the "static" keyword prevents that, forcing
> the linker to not merge these redundant functions.
> 
> Cheers,
> Benoit

Hi! I come from the future, it is not in C++17. 
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to