2015.04.13 18:03 "[Tiff] Reliable way to detect library version", by Larry Gritz

2015.04.13 18:03 "[Tiff] Reliable way to detect library version", by Larry Gritz

I had been using

#if TIFFLIB_VERSION >= 20120922

to detect whether it was safe to use TIFFCreateEXIFDirectory (which is present in libtiff 4.x, but not 3.x), but it's recently come to my attention that libtiff 3.9.7 also defines TIFFLIB_VERSION as 20120922 but lacks that API call.

It seems clear to me now that I must have written this line comparing 3.9.6 versus 4.0.3 and assuming the number would increase monotonically for future versions, understandable given that the comment in tiffvers.h says:

But now I see that 4.0.2 has an older date than 3.9.7.

So... what's the best/official way to reliably detect which TIFF version we have, at build time, in order to avoid compilation errors when using newer API calls that may or may not be present in the installed libtiff on the build machine?

--
Larry Gritz
lg@larrygritz.com