Home >Backend Development >C++ >Why Do C and C Differ in Their Treatment of Namespace-Scope `const` Objects?
Internal Linkage with Const in C vs. C
It's a known fact that declaring a const object at namespace scope in C results in internal linkage, contrary to the behavior observed in C.
The rationale behind this distinction is explained in Appendix C of the C 11 standard (section C.1.2). It states that file-scope const objects are limited to internal linkage, even without an explicit extern declaration. This change serves two purposes:
The above is the detailed content of Why Do C and C Differ in Their Treatment of Namespace-Scope `const` Objects?. For more information, please follow other related articles on the PHP Chinese website!