Say I have a file, window.h, which defines:
extern const int window_width, window_height;
I don't want anyone to change these variables, so they're const for all includers of window.h. However, is it legal to declare them non-const in the source file?
// window.c
int window_width, window_height;
void onResizeWindow(int w, int h) {
window_width = w;
window_height = h;
}
This compiles without linker errors for me in Apple clang version 12.0.0 (clang-1200.0.22.7). But is it legal and well-defined C?