Dev Tools · 2h ago
Stop Using #define for Constants in C++: Use const and constexpr Instead
A developer argues that #define macros should not be used for constants in modern C++ due to lack of type safety and scoping. Instead, const should be used for runtime-immutable values and constexpr for compile-time constants. The article explains the differences between preprocessor, compile-time, and runtime stages.
Meridian48 take
The advice is sound for C++ developers, but the article's title overstates the problem—many experienced devs already know this.
c++best-practices