[MPlayer-dev-eng] libmpdemux/cache2.c: correct format strings given _FILE_OFFSET_BITS
a.guru at sympatico.ca
a.guru at sympatico.ca
Tue Aug 16 23:50:20 CEST 2005
* On Sunday 2005-08-14 at 12:42:34 +0200, Reimar Döffinger wrote:
> On Sun, Aug 14, 2005 at 05:20:20AM -0400, a.guru at sympatico.ca wrote:
>
> > I was thinking of renaming my new macros PRIdOFF
> > and PRIXOFF to follow that same pattern.
>
> Ok, but you should probably check that they aren't already defined.
I can wrap each #define with an #ifndef.
> > I am not familiar with MinGW, but here's the
> > obvious question: does its <inttypes.h> already
> > define PRId64 as "I64d"?
>
> Yes, it does. But the problem is that if you want to do this, you must
> make sure inttypes.h is included before you define that :-(
> mp_msg.h might be the right place in that case.
I will start with mp_msg.h
> Exactly. Though we would have to test if your patch can correctly detect
> the size under MinGW. I guess using sizeof is not possible in the
> preprocessor macro?
No, unfortunately.
I checked MinGW's <sys/types.h> and it seems
that off_t is always typedef:ed as a long.
This is not real detection, but it means that
we can just use "ld" and "lX", and not care what
a long is (32 or 64 bits).
> But actually there would be a different possibility: always use PRId64
> and cast the offsets to int64_t. Because finding the right place for the
> #ifdefs is non-trivial, as well as detecting the size of off_t I
> actually think this might be the more "stable"/portable way.
Yes, but it's less "native" (the conversions are
overhead in the 32-bit case), so I'd still like
to give the PRIdOFF approach a shot first.
How about this (as a base)?
--- mp_msg.h.orig-1.0pre7 2005-01-20 08:22:52 -0500
+++ mp_msg.h 2005-08-16 17:31:28 -0400
@@ -136,4 +136,31 @@
#endif
#endif
+
+#ifdef __MINGW32__
+# ifndef PRIdOFF
+# define PRIdOFF "ld"
+# endif
+# ifndef PRIXOFF
+# define PRIXOFF "lX"
+# endif
+#else
+# include <inttypes.h>
+# if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64
+# ifndef PRIdOFF
+# define PRIdOFF PRId64
+# endif
+# ifndef PRIXOFF
+# define PRIXOFF PRIX64
+# endif
+# else
+# ifndef PRIdOFF
+# define PRIdOFF PRId32
+# endif
+# ifndef PRIXOFF
+# define PRIXOFF PRIX32
+# endif
+# endif
+#endif
+
#endif
More information about the MPlayer-dev-eng
mailing list