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. Thanks anyway. Regards, Anatoli On 22/10/20 22:09, Russell Shaw wrote: > > On 23/10/20 9:23 am, Anatoli wrote: >> Hi All, >> >> Is there a way to determine with autoconf what's the base type of a typedef? >> >> I'm trying to accomplish the following: >> >> There are standard types time_t, off_t, size_t and similar that are defined >> differently on different platforms/OS. >> >> For example, time_t is defined as "long int" on Linux amd64, but as "long >> long int" on OpenBSD amd64. So when printing a time_t var with printf & co, >> on Linux it's OK to use "%ld" format specifier, but on OpenBSD it should be >> "%lld". > You could use an AC_COMPILE thing to run a small bit of C that does something like: > > int > test(int argc, char **argv) > { > time_t t = -1; > > if(t < 0) { > if(sizeof(time_t) == sizeof(int)) { > printf("d"); > } > else if(sizeof(time_t) == sizeof(long int)) { > printf("ld"); > } > else if(sizeof(time_t) == sizeof(long long int)) { > printf("lld"); > } > else { > printf("error"); > } > } > else { > if(sizeof(time_t) == sizeof(int)) { > printf("u"); > } > else if(sizeof(time_t) == sizeof(long int)) { > printf("lu"); > } > else if(sizeof(time_t) == sizeof(long long int)) { > printf("llu"); > } > else { > printf("error"); > } > } > > return 0; > } >