Skip to content

Use standard C99 integer types

Roger Leigh requested to merge rleigh/libtiff:std-int-types into master

See discussion in !51 (closed)

Update the CMake and Autoconf logic to:

  • Search for stdint.h and inttypes.h
  • Use C99 integer types if present
  • Use C99 PRI* format string macros if present
  • Include stdint.h and inttypes.h conditionally; note the TIFF_ suffix on the HAVE_XXX_H macros; this is because they are in a public header
  • Retain fallbacks to pre-C99 types
  • Update printf usage to use PRI*-style macros with % in format string; update old fallbacks to use the same conventions

The way this has been done is to use exactly the same tiff_config.h logic already in use, so there is no API break with these changes. It's just a variant upon what we already have. There shouldn't be any ABI breakage either (but this will need checking).

We can take this further in the future, but this is the minimal set of changes to introduce C99 integer types without any disruption. The way the CMake and Autoconf logic has been updated leaves all the pre-C99 compatibility logic within a single else block; removing compatibility is as simple as removing the two blocks. We can also potentially update the public typedefs used in public interfaces, but I've left this for a followup MR.

I'll be doing some testing on a variety of platforms and architectures to make sure the detection logic is working correctly in all cases. I would certainly appreciate any testing and feedback for anyone who has time to review and test.

/cc @rouault @bobfriesenhahn @mitchblank

Edited by Roger Leigh

Merge request reports