miloyip / nativejson-benchmark

C/C++ JSON parser/generator benchmark
MIT License
1.97k stars 262 forks source link

ULib test fails #86

Open aldanor opened 7 years ago

aldanor commented 7 years ago

(I've ran ./configure --disable-shared && make, same as in travis config)

This is on OS X:

./../src/tests/ULibtest.cpp:47:23: error: calling 'begin' with incomplete return type 'UValueIter'
                        for (auto const& i : val)
                                           ^
../../thirdparty/ULib/include/ulib/json/value.h:841:22: note: 'begin' declared here
   friend UValueIter begin(const union jval);
                     ^
../../thirdparty/ULib/include/ulib/json/value.h:63:7: note: forward declaration of 'UValueIter'
class UValueIter;
      ^
../../src/tests/ULibtest.cpp:47:23: note: when looking up 'begin' function for range expression of type
      'const UValue::jval'
                        for (auto const& i : val)
                                           ^
../../src/tests/ULibtest.cpp:60:23: error: calling 'begin' with incomplete return type 'UValueIter'
                        for (auto const& i : val)
miloyip commented 7 years ago

@stefanocasazza

stefanocasazza commented 7 years ago

@aldanor I seem to understand that your compiler does not support CXX11, so can you apply this patch:

--- ULibtest.cpp    2017-03-24 16:10:17.000000000 +0100
+++ ULibtest.cpp.new    2017-06-01 13:24:39.925727535 +0200
@@ -44,12 +44,21 @@
            {
            stat.arrayCount++;

+#      if defined(U_STDCPP_ENABLE) && defined(HAVE_CXX11)
            for (auto const& i : val)
                {
                stat.elementCount++;

                GenStat(stat, i.getValue());
                }
+#      else
+           for (UValue* i = UValue::toNode(val.ival); i; i = i->next)
+               {
+               stat.elementCount++;
+
+               GenStat(stat, i->getValue());
+               }
+#      endif
            }
        break;

@@ -57,6 +66,7 @@
            {
            stat.objectCount++;

+#      if defined(U_STDCPP_ENABLE) && defined(HAVE_CXX11)
            for (auto const& i : val)
                {
                stat.memberCount++;
@@ -65,6 +75,16 @@

                GenStat(stat, i.getValue());
                }
+#      else
+           for (UValue* i = UValue::toNode(val.ival); i; i = i->next)
+               {
+               stat.memberCount++;
+               stat.stringCount++; // Key
+               stat.stringLength += UValue::getStringSize(i->getKey());
+
+               GenStat(stat, i->getValue());
+               }
+#      endif
            }
        break;
        }
boazsegev commented 4 years ago

@stefanocasazza ,

The error persists.

It's 2020 and I get the error with an updated Xcode compiler (Clang based on LLVM 9, which Apple versions as 11.0.3)...

...isn't it time to fix the default implementation instead of asking developers to patch the repo themselves?

B.