Author: smeenai Date: Thu Apr 13 15:13:32 2017 New Revision: 300246 URL: http://llvm.org/viewvc/llvm-project?rev=300246&view=rev Log: [libc++] Add _LIBCPP_DISABLE_EXTERN_TEMPLATE config option
When the libc++ extern template macros were added, the intent was for it to be possible for consumers of the headers to disable extern templates (via `-D_LIBCPP_EXTERN_TEMPLATE(...)=`). Unfortunately, support for specifying function-like macros varies on the command line varies across compilers (e.g. MSVC doesn't support it at all), and cmake doesn't allow it for the same reason. Add a non-function macro for this purpose. The intended use is for libraries which want to use the libc++ headers without taking a dependency on the libc++ library itself. I can name the macro something which reflects its intent rather than its behavior (e.g. `_LIBCPP_HEADER_ONLY`) if desired. Differential Revision: https://reviews.llvm.org/D31725 Modified: libcxx/trunk/docs/UsingLibcxx.rst libcxx/trunk/include/__config Modified: libcxx/trunk/docs/UsingLibcxx.rst URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/UsingLibcxx.rst?rev=300246&r1=300245&r2=300246&view=diff ============================================================================== --- libcxx/trunk/docs/UsingLibcxx.rst (original) +++ libcxx/trunk/docs/UsingLibcxx.rst Thu Apr 13 15:13:32 2017 @@ -146,6 +146,11 @@ thread safety annotations. build of libc++ which does not export any symbols, which can be useful when building statically for inclusion into another library. +**_LIBCPP_DISABLE_EXTERN_TEMPLATE**: + This macro is used to disable extern template declarations in the libc++ + headers. The intended use case is for clients who wish to use the libc++ + headers without taking a dependency on the libc++ library itself. + **_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION**: This macro is used to re-enable an extension in `std::tuple` which allowed it to be implicitly constructed from fewer initializers than contained Modified: libcxx/trunk/include/__config URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=300246&r1=300245&r2=300246&view=diff ============================================================================== --- libcxx/trunk/include/__config (original) +++ libcxx/trunk/include/__config Thu Apr 13 15:13:32 2017 @@ -856,6 +856,11 @@ template <unsigned> struct __static_asse # endif #endif +#ifdef _LIBCPP_DISABLE_EXTERN_TEMPLATE +#define _LIBCPP_EXTERN_TEMPLATE(...) +#define _LIBCPP_EXTERN_TEMPLATE2(...) +#endif + #ifndef _LIBCPP_EXTERN_TEMPLATE #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; #endif _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits