AX_PRINTF_SIZE_T
Check for the appropriate printf() format string modifier to use with a size_t argument. If a suitable modifier is found, it is AC_DEFINE’d as PRI_SIZE_T_MODIFIER, and can be used in C code as e.g.
printf("Size = %" PRI_SIZE_T_MODIFIER "u bytes.\n", sizeof(foo));
If you use the PRIxNN macros from ISO C99’s <inttypes.h>, you may wish to define a supplemental set of macros along similar lines:
#define PRIdSIZE PRI_SIZE_T_MODIFIER "d" #define PRIiSIZE PRI_SIZE_T_MODIFIER "i" #define PRIoSIZE PRI_SIZE_T_MODIFIER "o" #define PRIuSIZE PRI_SIZE_T_MODIFIER "u" #define PRIxSIZE PRI_SIZE_T_MODIFIER "x" #define PRIXSIZE PRI_SIZE_T_MODIFIER "X"
Note: This macro invokes a test program to check whether a given format modifier is understood by the system’s sprintf() function. If the user is cross-compiling, then this check cannot be performed, and thereby PRI_SIZE_T_MODIFIER will remain undefined.
Download the latest version of ax_printf_size_t.m4 or browse the macro’s revision history.
Copyright © 2012 Daniel Richard G. skunk@iSKUNK.ORG
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.