From 22059a230a11a010d2939cdfc3e4a933b0410e32 Mon Sep 17 00:00:00 2001 From: Tom Conerly Date: Mon, 17 Feb 2014 23:10:21 -0800 Subject: [PATCH] Fix clang folly::to failure Summary: Converting an enum class to a string fails with clang. Adfinder clang build failure is http://ci-fbcode.fb.com:8080/builders/project/builds/146520/steps/build/logs/stdio Our version of clang supports std::underlying_type so use that implementation instead. Test Plan: fbconfig -r folly && fbmake runtests (only failure is folly/experimental/symbolizer/test:symbolizer_test which failed before this diff) fbconfig --clang folly/test:conv_test && fbmake runtests (fbconfig -r --clang folly fails and fbconfig --clang folly/test && fbmake has some unrelated compile errors) Build adfinder with clang Reviewed By: delong.j@fb.com FB internal diff: D1178770 --- folly/Conv.h | 4 ++-- folly/test/ConvTest.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/folly/Conv.h b/folly/Conv.h index 12936cc3..8eb7e52c 100644 --- a/folly/Conv.h +++ b/folly/Conv.h @@ -379,7 +379,7 @@ toAppend(Src value, Tgt * result) { toAppend(static_cast(value), result); } -#if defined(__GNUC__) && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) +#if defined(__clang__) || __GNUC_PREREQ(4, 7) // std::underlying_type became available by gcc 4.7.0 /** @@ -1071,7 +1071,7 @@ to(const Src & value) { * Enum to anything and back ******************************************************************************/ -#if defined(__GNUC__) && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) +#if defined(__clang__) || __GNUC_PREREQ(4, 7) // std::underlying_type became available by gcc 4.7.0 template diff --git a/folly/test/ConvTest.cpp b/folly/test/ConvTest.cpp index 49da954d..3cd09149 100644 --- a/folly/test/ConvTest.cpp +++ b/folly/test/ConvTest.cpp @@ -592,7 +592,7 @@ TEST(Conv, UnsignedEnum) { } } -#if defined(__GNUC__) && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) +#if defined(__clang__) || __GNUC_PREREQ(4, 7) // to and to(enum class) only supported in gcc 4.7 onwards TEST(Conv, UnsignedEnumClass) { -- 2.34.1