...

/

__has_include Preprocessor Expression

__has_include Preprocessor Expression

Let's look at how we can use the `__has_include` preprocessor expression to check if a given header exists.

We'll cover the following...

__has_include

If your code has to work under two different compilers, then you might experience two different sets of available features and platform-specific changes.

In C++17 you can use __has_include preprocessor constant expression to check if a given header exists:

#if __has_include(<header_name>)
#if __has_include("header_name")

__has_include was available in Clang as an extension for many years, but now it was added to the Standard. It’s a part of “feature testing” helpers that allows you to check if a ...