Re:Add a const here, delete a const there
by brucedawson on Monday January 09, 2017 @09:01PM
(#13361905)
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.
The C++ standard doesn't mandate this, but good toolchains do put constant data in a separate read-only segment.