#define, int or const int

darkroomsource:
But as you have so clearly pointed out, after 30+ years of programming! I clearly know nothing.

Maybe not nothing, but my guess is that your 30+ years of programming isn't 30+ years of C
programming and using macros because you seem to have a big misunderstanding of how cpp works.
How cpp does macro expansion and substitution hasn't really changed in 30+ years at least
not with respect to the simple substations in your examples.

In terms of why const may be better than defines
"it depends"
There are things that each can do that the other can't.

For simple uses of integer values that are constant,
const is usually the better choice as it can offer type checking and is less likely to create odd errors
when there is a typo somewhere.

defines/macros can be used to do things that simple const variables can't
and in those cases, obviously macro defines must be used.

My assumption is that some of the #define use in examples where a const probably
would have been more appropriate is from the old guys
like me that have been doing C coding in embedded environments
for 30+ years and way back then there was no such thing as const, no function prototypes,
there was no C++, optimizers were iffy at best, so the best way to ensure you got compact
efficient code was often to use and push cpp to its limits.
Using a #define back then often generated better code than using a variable since
optimizers were not as good as they are today.
In the early days, everything was often essentially the same as todays "volatile"
so if you declared something as a variable vs a define, it used memory and hit memory
every single time you referenced it.
Back then the code generated was often about what you get with todays gcc with
optimization turned off.

You can still get decent code without the optimizer turned off, but the
code you get will vary quite a bit depending on how you write it.

Essentially, since const didn't exist back then, , #define was what you used for constants.

And so for some of us that have been around for C for 30+ years,
those old habits and optimization techniques learned
over the decades are still being used even though many are no longer necessary.

--- bill