Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

access const variables accross translation units

In C++, const variables are implicitly hidden from other translation units. Is is possible to prevent that?

like image 630
fredoverflow Avatar asked Feb 03 '26 07:02

fredoverflow


1 Answers

Yes, prefix the definition with extern eg.

extern const int x = 10;
like image 71
Troubadour Avatar answered Feb 04 '26 21:02

Troubadour



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!