Consider these two C++ header cases:
Case 1:
class Test {
public:
static int TEST_DATA[];
};
int Test::TEST_DATA[] = { 1, 2, 3, 4 };
Case 2:
class Test {
public:
static int const TEST_DATA[];
};
int const Test::TEST_DATA[] = { 1, 2, 3, 4 };
Is const in the latter case only for self-imposed compile-time checks or does it affect shared library layout on Mac/Linux/Windows?
Update: According to the answers, the compiler may put the const stuff on a read-only page. Does Visual C++ on Windows or GCC on Mac or Linux actually place const data on a read-only page? Perhaps I tested the wrong way but on Mac on Intel, the elements of the const version seemed writable.