Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The new feature of C++17 'inline variable' vs 'extern' keyword inherited from C [closed]

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

like image 375
Zeyd Avatar asked Oct 28 '25 19:10

Zeyd


1 Answers

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.

like image 162
Maxim Egorushkin Avatar answered Oct 30 '25 09:10

Maxim Egorushkin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!