#1995 Macros in float.h

Ben Shi

There are macros in float.h, which shouldn't be there, according to the standard and may break standard-compliant code by namespace pollution:

#define EXCESS 126
#define SIGNBIT ((unsigned long)0x80000000)
#define HIDDEN (unsigned long)(1ul << 23)
#define SIGN(fp) (((unsigned long)(fp) >> (8*sizeof(fp)-1)) & 1)
#define EXP(fp) (((unsigned long)(fp) >> 23) & (unsigned int) 0x00FF)
#define MANT(fp) (((fp) & (unsigned long)0x007FFFFF) | HIDDEN)
#define NORM 0xff000000
#define PACK(s,e,m) ((s) | ((unsigned long)(e) << 23) | (m))



  • Ben Shi

    Ben Shi - 2015-06-18

    I saw many library files in sdcc/device/ used these macros. How about embrace them with a " # ifndef __SDCC_FLOAT_EXT__ / # endif " ?

    Then we define __SDCC_FLOAT_EXT__ in the library files, and the above macros do not pollute the namespace in other source files.

    Last edit: Maarten Brock 2015-06-29
  • Ben Shi

    Ben Shi - 2015-06-26

    Fixed in reversion [r9263].



    Commit: [r9263]

    Last edit: Maarten Brock 2015-06-30
  • Ben Shi

    Ben Shi - 2015-06-26
    • status: open --> closed-fixed
    • assigned_to: Ben Shi
    • Category: --> other
  • Maarten Brock

    Maarten Brock - 2015-06-29

    Ben, did you forget to commit the library files that should now have this new macro defined before the include of float.h?

    • Ben Shi

      Ben Shi - 2015-06-29

      No. Maarten,

      If I forgot, there could be many compling errors leading to failures of daily snapshot builds.

      Actually, in previous version of each library file using these extended macros, the conditional macro is already defined before incluing float.h.


      • Maarten Brock

        Maarten Brock - 2015-06-30

        I replied because I was expecting failing snapshots.

        But you're right. Everything was already there.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks