2021.01.04 14:23 "[Tiff] Motions related to C99 use in libtiff", by Even Rouault

2021.01.11 13:28 "Re: [Tiff] Motions related to C99 use in libtiff", by Roger Leigh

>#define TIFF_LEGACY_TYPES

Could that (maybe combined with TIFFLIB_VERSION) be made the official transition method both for building libtiff and for packages including headers that include tiff headers that all need to agree on what to do, so a package that wants to update could

#include <tiffvers.h>
#if (TIFFLIB_VERSION > 20210101) && !defined(TIFF_LEGACY_TYPES)

safe to #include headers that conflict with the legacy types

Could TIFF_LEGACY_TYPES be 0 or 1 instead of just defined/not defined so tiffio.h could temporarily

#ifndef TIFF_LEGACY_TYPES
#if defined(_STDINT_H) || (__STDC_VERSION__ >= 199901L)
#define TIFF_LEGACY_TYPES 0
#else
#define TIFF_LEGACY_TYPES 1

> …

Hi William,

Your example above is conflating two different problems/questions:

These are two orthogonal problems.

The first problem, checking for and enabling the use of C99 stdint.h, inttypes.h and the C99 integer types is handled entirely by Autoconf or CMake. It checks for their availability and enables them conditionally if present, otherwise it falls back to the existing behaviour. That is the std-int-types branch. It requires no action on the part of client code.

The second problem, enabling the legacy types is (in my patchset) something which can be done irrespective of whether the C99 types or the old C types are in use. For example, it doesn’t matter if "uint16” is actually “unsigned short” or “uint16_t”. For compatibility, the important factor is that the type name exists and that it is a 16-bit unsigned type. If you want to compile code using the legacy typenames, then you’ll want to enable the legacy type names irrespective of whether you are using a C99 compiler or an older compiler.

In the opposite case, where the client code is already using C99 integer types, you can use an old or new libtiff with or without the legacy types enabled, without any API compatibility issues. You don’t use the legacy type names so you don’t need to care either way.

I don’t see a situation where you would want to *conditionally* use the legacy types. Your code either needs them, or it doesn’t. You would enable them either directly in the sources or via CFLAGS as a transitional mechanism, prior to your code dropping use of them. And then you would disable them once you have done the migration. If you want to build with both old and new versions of libtiff, then you can leave them unconditionally enabled as long as you like.

The only exception to this is in the case that you are using another library with clashing typedefs. In this situation, you’re not going to be compiling with an older version of libtiff because it is broken for this use case. You’re going to use a new release with the legacy types disabled, because that’s the only working combination available and there isn’t an alternative.

Kind regards,

Roger