Earlier quoted context omitted.
> In Rust we'd use `const` for this but in C you need to use the C pre-processor language instead to make constants, which is kinda wild. I get that you're not very familiar with C? Because in C we'd use const as well. const int x = 2; x = 3; // error: assignment of read-only variable 'x'
That's not a constant, that's an immutable variable which is why your diagnostic said it was read-only. const int x = 2; int *p = &x; *p = 3; // Now x is 3 And since I paid for the place where I'm writing this with cash earned writing C a decade or so ago, I think we can rule out "unfamiliar with C" as a symptom.
In my opinion it's a bit disingenuous to argue that it isn't a const just because you can ignore the compiler and shoot yourself in the foot. If you listen to the compiler, it is reflected in the assembly that it is a constant value the same as #define x 2.
Is Rust better at enforcing guarantees? Of course. Is `const` in C `const` if you don't ignore compiler warnings and errors? Also of course.
> And since I paid for the place where I'm writing this with cash earned writing C a decade or so ago
Ditto!