From 2549fb3c263e2d50630e5f42c0ff404b76cb7370 Mon Sep 17 00:00:00 2001 From: Peter Griess Date: Tue, 10 Sep 2013 11:36:38 -0500 Subject: [PATCH] Handle libc++ usage of inline namespaces for std:: Summary: - libc++ uses inline namespaces in its implementation of the std namespace; use its macros for our forward-declaring needs. @override-unit-failures The hphp_packedtv test has been sitting postponed for a long time. I can't repro its failure locally anyway. Test Plan: - fbconfig -r folly && fbmake runtests - ./configure && make check on Ubuntu/FC/Mac Reviewed By: simpkins@fb.com FB internal diff: D998578 --- folly/Portability.h | 11 +++++++++++ folly/Traits.h | 6 ++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/folly/Portability.h b/folly/Portability.h index 1095164f..9b77b5f5 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -118,4 +118,15 @@ struct MaxAlign { char c; } __attribute__((aligned)); # define FOLLY_DISABLE_ADDRESS_SANITIZER #endif +// It turns out that GNU libstdc++ and LLVM libc++ differ on how they implement +// the 'std' namespace; the latter uses inline namepsaces. Wrap this decision +// up in a macro to make forward-declarations easier. +#ifdef _LIBCPP_VERSION +#define FOLLY_NAMESPACE_STD_BEGIN _LIBCPP_BEGIN_NAMESPACE_STD +#define FOLLY_NAMESPACE_STD_END _LIBCPP_END_NAMESPACE_STD +#else +#define FOLLY_NAMESPACE_STD_BEGIN namespace std { +#define FOLLY_NAMESPACE_STD_END } +#endif + #endif // FOLLY_PORTABILITY_H_ diff --git a/folly/Traits.h b/folly/Traits.h index 47092973..f5fe5816 100644 --- a/folly/Traits.h +++ b/folly/Traits.h @@ -23,6 +23,8 @@ #include #include +#include "folly/Portability.h" + #include #include @@ -223,7 +225,7 @@ template struct IsZeroInitializable * although that is not guaranteed by the standard. */ -namespace std { +FOLLY_NAMESPACE_STD_BEGIN template struct pair; @@ -247,7 +249,7 @@ template template class shared_ptr; -} +FOLLY_NAMESPACE_STD_END namespace boost { -- 2.34.1