[bug #57114] Do not #define abs / labs

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[bug #57114] Do not #define abs / labs

Kevin Cuzner-2
URL:
  <https://savannah.nongnu.org/bugs/?57114>

                 Summary: Do not #define abs / labs
                 Project: AVR C Runtime Library
            Submitted by: gjlayde
            Submitted on: Fri 25 Oct 2019 08:42:00 AM UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
        Percent Complete: 0%
             Assigned to: None
        Originator Email:
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 2.0.0
           Fixed Release: None

    _______________________________________________________

Details:

#define'ing abs is evil, in particular together with C++ when there are
methods called abs or there is abs polymorphism.

Same for labs.

The patch provides proper functions (kind of) without introducing overhead.

        * include/stdlib.h (__ATTR_ALWAYS_INLINE__): New macro.
        (abs): Provide in such a way that we get a prototype.
        (labs): Same.




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Fri 25 Oct 2019 08:42:00 AM UTC  Name: stdlib-abs.diff  Size: 1KiB   By:
gjlayde

<http://savannah.nongnu.org/bugs/download.php?file_id=47738>

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?57114>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/