Summary: On some platforms (iPhone 5C at least), ObjC/Objc++ BOOL is really signed char. There is code which expects this to be a boolean when converted to dynamic (and then to JSON and into JS), but the old code treated it as a number. This makes such code (like [mobileConfig getBool:]) fail to compile, so the developer needs to resolve the ambiguity one way or the other.
Reviewed By: yfeldblum
Differential Revision:
D4648133
fbshipit-source-id:
76ece7803a1e966dca08bdb857af7990035544a0
namespace folly {
+#if __OBJC__
+constexpr auto kIsObjC = true;
+#else
+constexpr auto kIsObjC = false;
+#endif
+
#if defined(__linux__) && !FOLLY_MOBILE
constexpr auto kIsLinux = true;
#else
template <class T>
struct dynamic::NumericTypeHelper<
T, typename std::enable_if<std::is_integral<T>::value>::type> {
+ static_assert(
+ !kIsObjC || sizeof(T) > sizeof(char),
+ "char-sized types are ambiguous in objc; cast to bool or wider type");
using type = int64_t;
};
template <>