1

What's the difference between the inline specifier and the extern keyword when applied to a variable?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Zeyd
  • 59
  • 2
  • Related: [How do inline variables work?](https://stackoverflow.com/questions/38043442/how-do-inline-variables-work) – Borgleader May 31 '18 at 11:49

1 Answers1

6

extern says that the variable definition resides in a translation unit elsewhere.

inline for global/namespace scope variable means that the definition is provided at the spot. Without inline or const there will be multiple symbol definition linker error.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271