What's the difference between the inline specifier and the extern keyword when applied to a variable?
Asked
Active
Viewed 530 times
-1
Remy Lebeau
- 505,946
- 29
- 409
- 696
Zeyd
- 39
-
Related: [How do inline variables work?](https://stackoverflow.com/questions/38043442/how-do-inline-variables-work) – Borgleader May 31 '18 at 11:49
1 Answers
5
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
- 125,859
- 15
- 164
- 254
-
inline variable has same address in all translation units same thing for the extern variable. – Zeyd May 31 '18 at 11:58
-