I'm writing a conversion specifier (
%b) to be able to print any unsigned integer type in binary.
Here is the full code of it: https://codereview.stackexchange.com/questions/219994/register-b-conversion-specifier
Everything seems to work right now, but there's the possibility that
sizeof(uintmax_t) > sizeof(unsigned long long)
And the same with
And glibc only seems to pass info about "normal" integer types (
unsigned + length modifiers or
char). Is it just impossible right now to prepare for that? Maybe because there is no implementation yet where those two types are wider (AFAIK).
How does glibc handle the
z length modifiers? Probably they just are registered as equivalents to
ll, and don't have a different handling.
There seems to be some hint that there may exist the possibility of handling types other than the basic ones.
/* Type of a printf specifier-arginfo function. INFO gives information about the format specification. N, ARGTYPES, *SIZE has to contain the size of the parameter for user-defined types, and return value are as for parse_printf_format except that -1 should be returned if the handler cannot handle this case. This allows to partially overwrite the functionality of existing format specifiers. */ typedef int printf_arginfo_size_function (const struct printf_info *__info, size_t __n, int *__argtypes, int *__size);
And also another hint in the deprecated old functions:
/* Old version of 'printf_arginfo_function' without a SIZE parameter. */ typedef int printf_arginfo_function (const struct printf_info *__info, size_t __n, int *__argtypes); /* Obsolete interface similar to register_printf_specifier. It can only handle basic data types because the ARGINFO callback does not return information on the size of the user-defined type. */ extern int register_printf_function (int __spec, printf_function __func, printf_arginfo_function __arginfo) __THROW __attribute_deprecated__;