_hasinclude is a preprocessor macro that allows you to check whether a header file is available before including it in your code. It is useful when writing cross-platform code that might require different header files on different systems.
The correct way to utilize _hasinclude is to use it in a conditional statement, like this:
#if __has_include(<header_file>)
// header file is available
#include <header_file>
#else
// header file is not available
#endif
Replace <header_file>
with the name of the header file you want to check for. The code inside the #if
block will only be compiled if the header file is available, otherwise the code inside the #else
block will be compiled instead.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-06-01 11:00:00 +0000
Seen: 16 times
Last updated: Apr 22 '21