Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: printf format question

  I know I'm mising something totally basic and obvious, but what format
  specifier should I use when printing a variable of type clock_t ?

  On amd64, a clock_t is typedef'd to "unsigned int" and printf %u works
  fine.  But on i386, clock_t is typedef'd to "unsigned long" and
  requires printf %lu, and both %u and %llu fail to compile.  There
  doesn't seem to be any entry in i386/int_fmtio.h that equates to %lu

One approach is to demand that the header file that defines clock_t also
define macros so that one can write PRI(clock_t) or PRI_clock_t to get
the appropriate format specifier.  That would just be an extra define
where clock_t is defined.

Or convert the kernel to C++ and use cout << :-)

But Joerg's suggested approach is easier.

Attachment: pgpQcuVm2Hn9F.pgp
Description: PGP signature

Home | Main Index | Thread Index | Old Index