[flac-dev] [Flac-dev] Git branch with compiling fixes for win32

Erik de Castro Lopo
Wed, 01 Feb 2012 10:52:38 -0000

JonY wrote:

> Alright, here's a quick fix, although it is more ugly than I
remembered.
>
> Basically, it removes those _MSC_VER ifdefs, and relies on inttypes.h
> where available, and falls back to I64 on MSVC and then ll for others,
> all format warnings suppressed.

JonY,

Sorry for the delay on actually getting on to this.

I tried your patch, but it wasn't quite right. The problem is that %ll
is the correct format specifier for uint64_t on 32bit Linux but not
on 64 bit Linux.

In C99, the correct way to print a uint64_t value is:

     printf ("THe value is : " PRIu64 "\n", value) ;

I have gone ahead and fixed this through the code and fixed this, but I
may have broken some either MSVC or MinGW on the way. I'd appreciate it
if you test whats in git now.

For those files where any compiler baulks at the PRIu64/PRIx64/PRId64,
you should add a #ifdef block that might look something like:

    #ifdef HAVE_INTTYPES_H
    #include <inttypes.h>
    #else
    #if defined (_MSC_VER) && ! defined (PRId64)
    #define PRId64 "I64d"
    #endif
    #if defined (_MSC_VER) && ! defined (PRIu64)
    #define PRIu64 "I64u"
    #endif
    #endif

We'll worry about compilers that don't have the PRI_64 values as we find
them.

Cheers,
Erik
--
----------------------------------------------------------------------
Erik de Castro Lopo