In C , the 'const' keyword denotes a constant variable or object. Contrary to C, in C , declaring a constant at namespace scope implies internal linkage rather than external linkage.
Appendix C (C 11, C.1.2) provides the reasoning behind this distinction:
"A name of file scope that is explicitly declared const, and not explicitly declared extern, has internal linkage, while in C it would have external linkage."
This modification was introduced to encourage explicit initialization values for constant objects, leveraging their use as compile-time values in C . By allowing the placement of const objects in header files included in multiple compilation units, this feature enhances code organization.
The above is the detailed content of Why Does `const` Imply Internal Linkage in C but External Linkage in C?. For more information, please follow other related articles on the PHP Chinese website!