Re: [pcre-dev] pcrecpp_unittest failed in 7.2 on Mingw32

Página Principal
Apagar esta mensagem
Autor: Craig Silverstein
Data:  
Para: ph10
CC: pcre-dev
Assunto: Re: [pcre-dev] pcrecpp_unittest failed in 7.2 on Mingw32
Hey philip, did you ever resolve this "%lld" vs "%I64d" problem?

} Or can we detect MinGW automatically, and use it in that case only?

I think this is the best way. I don't have MinGW myself, but looking
on the web it seems there's a #define we can use. I've attached a
patch below which should fix up the unittest.

craig

--cut here--

Index: pcrecpp_unittest.cc
===================================================================
--- pcrecpp_unittest.cc    (revision 189)
+++ pcrecpp_unittest.cc    (working copy)
@@ -905,6 +905,11 @@
     CHECK(!RE("(\\d+)").FullMatch("4294967296", &v));
   }
 #ifdef HAVE_LONG_LONG
+# if defined(__MINGW__) || defined(__MINGW32__)
+#   define LLD "%I64d"
+# else
+#   define LLD "%lld"
+# endif
   {
     long long v;
     static const long long max_value = 0x7fffffffffffffffLL;
@@ -914,18 +919,18 @@
     CHECK(RE("(-?\\d+)").FullMatch("100", &v)); CHECK_EQ(v, 100);
     CHECK(RE("(-?\\d+)").FullMatch("-100",&v)); CHECK_EQ(v, -100);


-    snprintf(buf, sizeof(buf), "%lld", max_value);
+    snprintf(buf, sizeof(buf), LLD, max_value);
     CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, max_value);


-    snprintf(buf, sizeof(buf), "%lld", min_value);
+    snprintf(buf, sizeof(buf), LLD, min_value);
     CHECK(RE("(-?\\d+)").FullMatch(buf,&v)); CHECK_EQ(v, min_value);


-    snprintf(buf, sizeof(buf), "%lld", max_value);
+    snprintf(buf, sizeof(buf), LLD, max_value);
     assert(buf[strlen(buf)-1] != '9');
     buf[strlen(buf)-1]++;
     CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));


-    snprintf(buf, sizeof(buf), "%lld", min_value);
+    snprintf(buf, sizeof(buf), LLD, min_value);
     assert(buf[strlen(buf)-1] != '9');
     buf[strlen(buf)-1]++;
     CHECK(!RE("(-?\\d+)").FullMatch(buf, &v));