Re: determine base type of a typedef

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

 



Russell,

> If a platform has time_t the same size as a long and long long, does
> it matter whether the printf uses "%ld" or "%lld" ?

>From my first mail:

> For GNU C this is "the same" as both are of 8 bytes, but clang
> generates a warning like: "warning: format specifies type 'long' but
> the argument has type 'time_t' (aka 'long long')".

Clang warns that it's not OK, though I'm not sure why exactly.


On 23/10/20 04:06, Russell Shaw wrote:
> On 23/10/20 5:54 pm, Anatoli wrote:
>> Russell,
>>
>> Thanks for your suggestion. The problem is, as I mentioned in the initial
>> post, on amd64 sizeof(time_t) is always 8 bytes, as well as long and long
>> long, so sizeof(time_t) == sizeof(long int) == sizeof(long long int).
>>
>> I've actually tried the following directly in configure.ac (for this test
>> it's not needed to run a custom code):
>>
>> #if (SIZEOF_TIME_T == SIZEOF_LONG_LONG_INT) #define TIME_T_FMT "%lld" #elif
>> (SIZEOF_TIME_T == SIZEOF_LONG) #define TIME_T_FMT "%ld" #else #error dont
>> know what to use for TIME_T_FMT #endif
>>
>> But both checks are true so it makes no sense.
>>
>> I need something that would not depend on the size of the type. Not sure it's
>> even possible.
> I might be missing something simple because i got up too early.
> 
> If a platform has time_t the same size as a long and long long, does it matter whether the printf uses "%ld" or "%lld" ?
> 




[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux