Ethereal-dev: [Ethereal-dev] Fun PRI[doxu]64 problem on AIX 4.3.2 for 0.10.5

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Albert Chin <[email protected]>
Date: Mon, 12 Jul 2004 23:50:23 -0500
For AIX 4.3.2 (not 4.3.3 or 5.x), <sys/inttypes.h> has:
  #define PRId8           %hd
  #define PRId16          %hd
  #define PRId32          %d
  #if defined(__64BIT__)
  #define PRId64          %ld
  #else
  #if defined(_LONG_LONG)
  #define PRId64          %lld
  #endif

Because it has the '%', this screws up the autoconf test:
  checking whether inttypes.h defines the PRI[doxu]64 macros... no
because it assumes the PRI macros do not contain a %:
  AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]])
  AC_COMPILE_IFELSE(
  ...
    [
      AC_LANG_SOURCE(
        [[
          #include <inttypes.h>
          #include <stdio.h>
          #include <sys/types.h> 

          main()
          {
            printf("%" PRId64 "\n", ($ac_ethereal_uint64_t_type)1);
            printf("%" PRIo64 "\n", ($ac_ethereal_uint64_t_type)1);
            printf("%" PRIx64 "\n", ($ac_ethereal_uint64_t_type)1);
            printf("%" PRIu64 "\n", ($ac_ethereal_uint64_t_type)1);
          }
        ]])
    ],

As the test fails, ethereal defines PRId64. But, because the IBM C
compiler does not like re#defining a macro, ./configure eventually
fails:
  ...
  "/usr/include/sys/inttypes.h", line 258.9: 1506-213 (S) Macro name
  PRId64 cannot be redefined.
  "/usr/include/sys/inttypes.h", line 258.9: 1506-358 (I) "PRId64" is
  defined on line 24 of conftest.c.
  "/usr/include/sys/inttypes.h", line 324.9: 1506-213 (S) Macro name
  PRIo64 cannot be redefined.
  "/usr/include/sys/inttypes.h", line 324.9: 1506-358 (I) "PRIo64" is
  defined on line 25 of conftest.c.
  ...

What is the best way to fix this? I think the easiest fix is to define
the PRIx64 macros with % and have two autoconf tests for PRI, one
testing without the '%', and one with.

-- 
albert chin ([email protected])