Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • I suggest typedefs. Lots of typedefs. Lots of typedefs that build on one another. Enough typedefs that you hate life to such a degree that you avoid such foolishness in the future. Yes, the distinction could be important. No, I have never seen production code where it mattered. Commented Nov 6, 2019 at 21:06
  • To be fair: "I have never NOTICED code where it mattered", in my 20+ year career as a programmer, most of which has been spent in C++. Commented Nov 6, 2019 at 21:06
  • this is more for my understanding of const-correctness than in order to write production code. I did stumble over it when I tried to replace a statically allocated static const char* foo[1000] with a dynamically allocated static char** foo and the compiler didn't allow me to assign string literals to the elements of foo Commented Nov 6, 2019 at 21:09
  • The const keyword binds to the thing to its immediate left. (Unless const appears very first, in which case it binds to the thing to its immediate right.) Commented Nov 6, 2019 at 22:13
  • It’s worth noting that const-correctness isn’t a purely academic question if you write for embedded systems. In embedded applications, the const keyword signals an intention that the item should be stored in the device’s Program ROM rather than copied from that ROM to program RAM on startup. Most embedded systems have more ROM than RAM, so this is an important distinction when you’re close to the system’s memory limits. Commented Jan 3, 2024 at 12:25