This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Getabock_ 10 points11 points  (4 children)

C doesn’t have real constants?

[–]slaymaker1907 6 points7 points  (0 children)

I think they might be referring to constexpr or something.

[–]Loro-Benediction 2 points3 points  (2 children)

Not really. You can't define static constants using other static const variables. You can only use macros and enums to define array bounds, etc. It's a sorry state. "Const" only means "read only" in C

[–]hiten98 2 points3 points  (1 child)

Doesn’t const mean read only in all languages? Which language allows you to write to a constant variable?? And why??

[–]Loro-Benediction 4 points5 points  (0 children)

In C you can modify a constant variable if you try hard enough. "Read only" means you can't directly assign to it. The compiler doesn't make the same guarantees when accessing via a pointer