autoconf
[Top][All Lists]
Advanced

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

Re: determine base type of a typedef


From: Bob Friesenhahn
Subject: Re: determine base type of a typedef
Date: Mon, 26 Oct 2020 10:48:00 -0500 (CDT)
User-agent: Alpine 2.20 (GSO 67 2015-01-07)

On Fri, 23 Oct 2020, Vivien Kraus wrote:

Is it not possible to always use "%lld" and always convert the
arguments to (long long int)?

The way I have been doing things for many years is to get the size of the underlying type and then include a cast in the printf arguments to a type of the same size. The need to add a cast is a bit messy, but then then again, just about everything related to printf is messy.

So create a define for the time_t formatter, and a define/typedef for the type to cast to.

The approach that Paul Eggert suggests is very interesting, but it might not provide absolute proof of the C type since the compiler/linker might allow success if the types are the same size. A printf syntax checker might not use the same rules.

Anything involving executing code should be avoided as much as possible since it hurts cross compilation.

Anything involving recent C standards should be avoided since it harms portability.

Bob
--
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
Public Key,     http://www.simplesystems.org/users/bfriesen/public-key.txt



reply via email to

[Prev in Thread] Current Thread [Next in Thread]