This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Extending vfprintf and family
- From: Philip Prindeville <philipp_subx at redfish-solutions dot com>
- To: Russ Allbery <eagle at eyrie dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Mon, 18 Aug 2014 19:23:35 -0600
- Subject: Re: Extending vfprintf and family
- Authentication-results: sourceware.org; auth=none
- References: <6B382F29-D813-41AA-ADA1-EDF9EE541704 at redfish-solutions dot com> <87oavm7vws dot fsf at hope dot eyrie dot org>
On Aug 14, 2014, at 12:45 PM, Russ Allbery <eagle@eyrie.org> wrote:
> Philip Prindeville <philipp_subx@redfish-solutions.com> writes:
>
>> When I was at Cisco in the IOS group, there was a way to register
>> on-the-fly additional format specifiers that *printf() could then
>> leverage; some of the formatting helpers were quite sophisticated,
>> understanding ASN.1 or X.509 certs, etc. Not sure we need to be that
>> complex, though I wouldn’t reject it if it were offered, either.
>
> glibc supports exactly this. See:
>
> https://www.gnu.org/software/libc/manual/html_node/Customizing-Printf.html#Customizing-Printf
Thanks, that was helpful. One thing that I don’t think was clear, though, is how the same specifier could handle a uint16_t, uint32_t, or uint64_t value. For instance, for a ‘Q’ specifier:
%hq
%q
%llq
as examples. What’s a portable way to retrieve a variable-sized scalar argument?
Thanks,
-Philip