Skip to content

Instantly share code, notes, and snippets.

@Eisenwave
Created July 20, 2023 11:46
Show Gist options
  • Save Eisenwave/5a649ac66f3a3d00303535d2dd69b7fc to your computer and use it in GitHub Desktop.
Save Eisenwave/5a649ac66f3a3d00303535d2dd69b7fc to your computer and use it in GitHub Desktop.
The Effect of `inline`, `static`, etc. on Symbols in C++

The Effect of inline, static, etc. on Symbols in C++

inline

  • Free function: Makes it an inline function. Linkage is unchanged, and external by default.
  • Static member function: Makes it an inline function. Linkage is the same as that of the class. inline is redundant for inline definitions, except when modules are used. In that case, inline would make the function part of the module interface as usual.
  • Non-static member functions: Makes it an inline function. The same rules for linkag and modules apply.
  • Global variables: Makes it an inline variable. Implies external linkage, even for const variables.
  • Static data members: Makes it an inline variable. The variable can be defined inside the class.
  • Local variables: Not allowed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment