C++ Logo

SG10

Advanced search

Subject: Re: [SG10] __has_include
From: Richard Smith (richard_at_[hidden])
Date: 2013-06-19 15:53:28


On Wed, Jun 19, 2013 at 1:36 PM, Nelson, Clark <clark.nelson_at_[hidden]> wrote:
> Thanks, Richard.
>
> On this topic, I remember that Walter suggested defining macros for new headers in <cstddef>, but I don't remember any specific reaction to that idea.
>
> Am I just forgetting, or did it actually slip by without comment?

I objected that I did not want including <cstddef> to require the
implementation to perform header search for <optional> and <dynarray>
(and whatever other headers we add in the future). I would expect
issuing these file system requests to have a measurable cost.

>> -----Original Message-----
>> From: features-bounces_at_[hidden] [mailto:features-bounces_at_open-
>> std.org] On Behalf Of Richard Smith
>> Sent: Wednesday, June 19, 2013 12:11 PM
>> To: features_at_[hidden]
>> Subject: [SG10] __has_include
>>
>> Starting with an example, here's how the new C++14 headers could
>> be
>> detected and used:
>>
>> #ifndef __has_include
>> #define __has_include(x) 0
>> #endif
>>
>> #if __has_include(<optional>)
>> #include <optional>
>> #endif
>>
>> #if __has_include(<dynarray>)
>> #include <dynarray>
>> #endif
>>
>>
>> Specification:
>>
>> __has_include is a predefined function-like macro.
>> __has_include(pp-tokens) expands to 1 if the preprocessing
>> directive
>>
>> #include pp-tokens
>>
>> would identify a header or source file (16.2/1). Otherwise, it
>> expands to 0.
>>
>>
>> Clang's documentation for __has_include is at
>> http://clang.llvm.org/docs/LanguageExtensions.html#include-file-
>> checking-macros
>> _______________________________________________
>> Features mailing list
>> Features_at_[hidden]
>> http://www.open-std.org/mailman/listinfo/features
> _______________________________________________
> Features mailing list
> Features_at_[hidden]
> http://www.open-std.org/mailman/listinfo/features


SG10 list run by sg10-owner@lists.isocpp.org