1993.12.20 11:15 "Problem with libtiff version 3.2 beta and Sun cc compiler", by Paolo Cavellini

1993.12.21 21:06 "Re: Problem with libtiff version 3.2 beta and Sun cc compiler", by Dan McCoy

I'm using LIBTIFF, Version 3.2 BETA on a Sun Sparc Workstation running SunOS 4.1.3

First off, the latest version of libtiff on sgi.com is 3.3 beta in the file:

         graphics/tiff/v3.3beta002.src.tar.Z

Is this a known bug of the Sun cc compiler?

This is a feature of pre-ANSI (or "K&R") C. In most implementations of K&R C, the parameter to the function a() is silently promoted to type "double" even though you said "float". When you pass the address of this to b() you are passing the address of a double, but b() thinks that it is the address of the float.

libtiff 3.3 uses ANSI-C prototypes. When the functions are properly prototyped a "float" stays a "float". Unfortunately, Sun's default compiler can't handle ANSI-C prototypes. You either need to buy Sun's "acc" compiler or use gcc for libtiff 3.3.

I looked at an old copy of libtiff 3.2beta that I have. The routine TIFFWriteRational there doesn't appear to have the problem you are talking about. The version of TIFFWriteRational in libtiff 3.3 would be susceptible to the problem, but 3.3 uses prototypes and shouldn't have the problem.

If you are really trying to coerce libtiff3.3 through Sun's cc (not something I would not want to do) or something else is going on and the code you are referring to is something like (from libtiff3.3):

        static int
        TIFFWriteRational(TIFF* tif,
            TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, float v)
        {
            return (TIFFWriteRationalArray(tif, type, tag, dir, 1, &v));
        }

You could fix that particular problem like so:

        static int
        TIFFWriteRational(TIFF* tif,
            TIFFDataType type, ttag_t tag, TIFFDirEntry* dir, float v)
        {
            float local_v = v;
            return (TIFFWriteRationalArray(tif, type, tag, dir, 1, &local_v));
        }

local_v, not being a parameter is always a float, never promoted to double.

Dan McCoy mccoy@pixar.com