C++ PATCH: PR 20599 (1/3)
Mon Sep 25 15:46:00 GMT 2006
Howard Hinnant wrote:
> On Sep 25, 2006, at 9:35 AM, Gabriel Dos Reis wrote:
>> | Without a feature-test macro, the library author will have to supply
>> | two separate implementations, and tell their clients: Use this
>> | version over here if you enable this feature, else use that version
>> | over there.
>> No. The *library author* defines the macros that guard its uses of
>> the specific GCC extensions. He/she does not need to provide two
>> separate implementations.
> Ah, sorry, I misunderstood your user interface:
> g++ my_source.cpp -D _STD_RVALUE_REF -D _STD_VARIADIC_TEMPLATES -D
> _STD_STATIC_ASSERT -D BOOST_RVALUE_REFS -D BOOST_VARIADIC_TEMPLATES - D
> BOOST_STD_STATIC_ASSERT -D ACME_RVALUE_REFS_ON -D
> ACME_USE_VARIADIC_TEMPLATES -D ACME_USE_STATIC_ASSERT -
> enable_rvalue_refs -enable_variadic_templates -enable_static_assert -
> lboost -lAcme
> I would prefer something more like:
> g++ my_source.cpp -enable_rvalue_refs -enable_variadic_templates -
> enable_static_assert -lboost -lAcme
FWIW, this is also our preference. We have requested most compiler
vendors to provide feature test macros for optional language features
because we find them to be more convenient (both for the authors of
the library as well as its users) in addition to being more reliable
than autodetecting the same set of features in each of our products.
That said, we also provide macros of our own to allow users to disable
the use of each library extension that depends on an optional language
feature even when it's enabled.
More information about the Libstdc++