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.
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
IMO, at this time, there is not that much value in providing this header (which is optional for freestanding implementations):
I'd suggest to add the header after implementing support for returning struct.
Philipp
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.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
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).
Added in [r14309], along with a whole bunch of previously missing library functions.
Related
Commit: [r14309]