Skip to content

[sprintf] Support for 16-bit int systems #1779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
stefano-zanotti-88 opened this issue May 4, 2025 · 0 comments
Open

[sprintf] Support for 16-bit int systems #1779

stefano-zanotti-88 opened this issue May 4, 2025 · 0 comments

Comments

@stefano-zanotti-88
Copy link
Contributor

The library makes various assumptions about the size of primitive types.
In particular, it assumes that sizeof(int) == 4.
It would be nice to be more standard and respect the actual int size of the system, as well as have better checks for the proper size to use for the 'j' 'z' 't'.
'z' now checks for the wrong type -- prdiff_t rather than size_t; and 'j' checks for 'size_t' rather than 'intmax_t', in order to avoid including more standard headers:

stb/stb_sprintf.h

Lines 543 to 555 in f056911

case 'j':
fl |= (sizeof(size_t) == 8) ? STBSP__INTMAX : 0;
++f;
break;
// are we 64-bit on size_t or ptrdiff_t? (c99)
case 'z':
fl |= (sizeof(ptrdiff_t) == 8) ? STBSP__INTMAX : 0;
++f;
break;
case 't':
fl |= (sizeof(ptrdiff_t) == 8) ? STBSP__INTMAX : 0;
++f;
break;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant