3 ms·
Adding const to globals is useful on most or all compilers. It deserves mention in C/C++ FAQs as a best practice. You can see this for yourself with simple test
by brucedawson 10y ago
Adding const to globals is useful on most or all compilers. It deserves mention in C/C++ FAQs as a best practice. You can see this for yourself with simple test apps using gcc and clang.
The C++ standard doesn't mandate this, but good toolchains do put constant data in a separate read-only segment.