Mailing List Archive


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

Re: [tlug] It's time_t to Party!



Stephen J. Turnbull wrote:

> 
> >>>>> "Jim" == Jim  <jep200404@example.com> writes:
> 
>     Jim> Unfortunately, I don't know how to say:
> 
>     Jim>    printf("%(type_t)d...",ts.tv_sec);
> 
> #if sizeof(type_t)==sizeof(long)
> #define TYPE_T_F "%ld"
> #endif
> 
>     printf (TYPE_T_F "...", ts.tv_sec);

I can't think of a better way to salvage printf(), 
especially if something like TYPE_T_F was adopted in the 
headers as a standard (if appropriate). 

I would make that a little bit more flexible by leaving 
out the '%' to allow for more modifiers: 

   #if sizeof(type_t)==sizeof(long)
   #define TYPE_T_F "ld"
   #elif
   #define TYPE_T_F "d"
   #endif

to allow for some craziness like: 

   printf("%-10.5" TYPE_T_F "...",ts.tv_sec);

Jim



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links