Menu

#597 Implement C99 header inttypes.h

None
closed-fixed
None
5
2023-08-17
2019-01-03
No

SDCC's library does not currently have an inttypes.h.

Its purpose is to provide conversion specifier macros and conversion function prototypes and it is described in section 7.8 (Format conversion of integer types) of the standard.

Related

Patches: #457
Wiki: SDCC 4.4.0 Release

Discussion

  • Philipp Klaus Krause

    IMO, at this time, there is not that much value in providing this header (which is optional for freestanding implementations):

    • I want to do a rewrite of the printf() family sometime (as there are some problems withthe current one), that would be a good time to add the macros from 7.8.1.
    • inttypes.h seems to be about imaxdiv_t a lot. But that type only makes sense once we have support for returning struct.

    I'd suggest to add the header after implementing support for returning struct.

    Philipp

     
    • Benedikt Freisen

      In that case my WIP implementation might already be useful to you.
      I don't want to commit it because it is 99.9% untested.
      Technically, I only need the #include <stdint.h> line but the other stuff was easy enough to add.

       
      • Philipp Klaus Krause

        The declarations for the conversion functions shouldn't be in aheader that ships with sdcc until we have implementation (which probably can be implemented as wrappers around exisiting functions).
        Otherise, this looks good. Thanks. We'd also want to have regression tests (might be possible to add that to exisiting tests, but could also be a new one instead).

        Philipp

         
      • Philipp Klaus Krause

        Having had another look at this, the header apparently relies on intptr_t being the same as ptrdiff_t. If so, this assumption should be checked via a Static_assert (even if we check only the size).
        It might happen that in the future, we support targets with sizeof(intptr_t) > sizeof(ptrdiff_t).

         
  • Benedikt Freisen

    • status: open --> closed-fixed
    • Group: -->
     
  • Benedikt Freisen

    Added in [r14309], along with a whole bunch of previously missing library functions.

     

    Related

    Commit: [r14309]


Log in to post a comment.