Git Product home page Git Product logo

Comments (4)

jungshik avatar jungshik commented on May 7, 2024

Note that ICU renamed utils.h to double-conversion-utils.h. Below is the error message from clang (in MSVC compatibility mode(?) on Windows)

../../third_party/icu/source/i18n/double-conversion-utils.h(342,20):  error: unused typedef 'VerifySizesAreEqual' [-Werror,-Wunused-local-typedef]
      typedef char VerifySizesAreEqual[sizeof(Dest) == sizeof(Source) ? 1 : -1];

from double-conversion.

jungshik avatar jungshik commented on May 7, 2024

Below is a suggested fix from @nico

#if __cplusplus >= 201103L
#define DOUBLE_CONVERSION_STATIC_ASSERT(expr, msg) static_assert(expr, #msg)
#else
namespace double_conversion {
template <bool> struct CompileAssert {};
}

typedef double_conversion::CompileAssert<static_cast<bool>(expr)> StaticAssert[bool(expr) ? 1 : -1]; \
(void)msg
#endif

DOUBLE_CONVERSION_STATIC_ASSERT(sizeof(Dest) == sizeof(Source));

Or just using 'typedef char ...' instead of struct template may work.

from double-conversion.

jungshik avatar jungshik commented on May 7, 2024

Somehow MSVC does not like that. This should work for both modern C++ compilers and a pre-C+11 compilers.

 #else
 #error Target architecture was not detected as supported by Double-Conversion.
 #endif
 
-#if defined(__GNUC__)
-#define DOUBLE_CONVERSION_UNUSED __attribute__((unused))
-#else
-#define DOUBLE_CONVERSION_UNUSED
-#endif
-
 #if defined(_WIN32) && !defined(__MINGW32__)
 
 typedef signed char int8_t;
@@ -336,8 +332,12 @@ template <class Dest, class Source>
 inline Dest BitCast(const Source& source) {
   // Compile time assertion: sizeof(Dest) == sizeof(Source)
   // A compile error here means your Dest and Source have different sizes.
-  DOUBLE_CONVERSION_UNUSED
-      typedef char VerifySizesAreEqual[sizeof(Dest) == sizeof(Source) ? 1 : -1];
+#if __cplusplus >= 201103L
+  static_assert(sizeof(Dest) == sizeof(Source),
+                "source and destination size mismatch");
+#else
+  typedef char StaticAssert[sizeof(Dest) == sizeof(Source) ? 1 : -1];
+#endif
 
   Dest dest;
   memmove(&dest, &source, sizeof(dest));

from double-conversion.

floitschG avatar floitschG commented on May 7, 2024

Could you please review
#68

Thanks

from double-conversion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.