[Flac-dev] VPATH and fixed-size integer data types

Matt Zimmerman mdz at debian.org
Tue Dec 4 23:42:14 PST 2001


I was fiddling around to get VPATH builds working again, and the only
nontrivial fix was for ordinals.h.  Because it is auto-generated, it goes in
the build directory, not the source directory, and thus requires some
fiddling to get included properly.  After looking at it, I don't see why it
needs to be auto-generated.  Rather than substituting in these values with
autoconf, they can just be defined in config.h (AC_DEFINE instead of
AC_SUBST).

However, an even better fix would be to use the ISO C header inttypes.h.
Here is what I do in another project:

AC_CHECK_HEADER(inttypes.h,
                [AC_DEFINE([HAVE_INTTYPES_H])],
                [AC_CHECK_TYPE(u_int8_t,
                               [AC_DEFINE([HAVE_U_INT])],
                               [AC_MSG_ERROR([Unable to find fixed-size data types])] )] )

and then in the header:

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#elif defined(HAVE_U_INT)
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define uint8_t u_int8_t
#define uint16_t u_int16_t
#define uint32_t u_int32_t
#define uint64_t u_int64_t
#else
#error Unable to find fixed-size data types
#endif

This works on (at least) recent Linux, Solaris and Cygwin32.  I assume it
works with the MS stuff as well.

If you want to keep the logic for detecting the size of various data types,
you can add the existing definitions instead of the #error, using
AC_DEFINE([FLaC__SIZE16], blah) etc.

Then ordinals.h doesn't have to be autogenerated anymore, we sidestep the
whole problem with VPATH, and also simplify things significantly, I think.

How about it?

-- 
 - mdz




More information about the Flac-dev mailing list