C++ Logo

sg10

Advanced search

Re: [SG10] __has_[cpp_]attribute

From: Stephen Kelly <steveire_at_[hidden]>
Date: Tue, 10 Jun 2014 00:39:57 +0200
Nelson, Clark wrote:

>> > Would it be fair to restate your questions as, why are we
>> recommending
>> > something like __has_attribute when we didn't recommend
>> __has_feature?
>
> I was actually hoping someone would provide an answer to that question.

Can we ask the person who proposed it?

> I myself am opposed -- weakly -- to the __has_attribute syntax, or some
> variation thereof, for all the reasons we didn't go with __has_feature in
> the first place, as I explained a couple of weeks ago.

I favor consistency between the feature test and the attribute test.

I weakly favor __has_foo() for these reasons:

1) For creating the consistency (at least from the users point of view) of
all such tests now and in the future being __has_foo().

For example, __has_builtin(is_final) might solve the problem here:

 http://www.open-std.org/pipermail/features/2014-May/000176.html

See

 http://thread.gmane.org/gmane.comp.compilers.clang.devel/34252


2) For making it harder for users to make mistakes such as

#ifdef __cpp_foo
#endif

when they meant

#if __cpp_foo
#endif

or

#if __cpp_foo > 201404
#endif

or

#if __cpp_foo >= 201404
#endif



I think __cpp_foo is fine because it might be easier to implement. However,
I would request consistent prefixes/namespacing to allow for growth in the
classes of tests recommended (eg builtins):

 http://thread.gmane.org/gmane.comp.lang.c++.isocpp.features/11

Thanks,

Steve.

Received on 2014-06-10 00:40:06