News for hackers. Stuff that matters.
Re:Rust and C++ Interoperability in Chrome by qppo on Wednesday August 19, 2020 @03:04PM (#24214712)
Even modern C++ has eschewed macros for virtually every use case, the only reason I've had to use them (legitimately) has been conditional compilation and some compiler/platform specific issues.

Like if you're doing #define PI 3.14159 you're asking to get chirped in code review.

Re:Rust and C++ Interoperability in Chrome by rightbyte on Wednesday August 19, 2020 @04:49PM (#24216223)
Ye, everyone know it is:

    #define PI 3.1415927410125732421875
that is the float closest to pi or that there is the GNU extension USE_FUNKY_DEFINES-something with M_PI for cmath. (I know you meant constexpr:ions).
Re:Rust and C++ Interoperability in Chrome by Const-me on Thursday August 20, 2020 @07:12AM (#24222017)
Long time ago when computers were 32-bit I used to write something like this in C++:

    inline double pi()
    {
        __asm fldpi;
    }
On old enough compilers, this will get you 80-bit version of pi, more precision than even double. Completely useless now, modern compilers no longer emit x87 code.
Re:Rust and C++ Interoperability in Chrome by asveikau on Thursday August 20, 2020 @12:19AM (#24219845)
math.h has M_PI in posix.
Re:Rust and C++ Interoperability in Chrome by qppo on Thursday August 20, 2020 @12:31AM (#24219911)
The point is that using macros for constants is frowned upon in modern codebases, just like all other use cases for macros that break type safety and the one definition rule.
Re:Rust and C++ Interoperability in Chrome by asveikau on Thursday August 20, 2020 @02:04AM (#24220367)
Yes, I understand the point. But to your comment in a literal sense, if I were doing code review I would probably suggest using M_PI. Which happens to be a macro.

Which actually highlights that many things you want to use for practical purposes are C rather than C++, predate innovations such as const or namespaces, etc. It's possible and common to understand the downsides and still reach for the macro.