Qt5 has a wrapper macro that makes __has_include simpler to use:
#ifdef __has_include # define QT_HAS_INCLUDE(x) __has_include(x) #else # define QT_HAS_INCLUDE(x) 0 #endif #if QT_HAS_INCLUDE(<chrono>) # include <chrono> #endif
The code handling this so far ignores macros entirely. This patch makes -frewrite-includes rewrite all #if/#elif conditions, which is more reliable and simpler than trying to handle __has_include specifically.
Adding an extra line here is going to mess up presumed line numbering. Also, we don't need parentheses around the constant 0 or 1. Perhaps instead we could prepend a #if 0 /* or #if 1 /* to the directive:
->
I don't think we really need the "evaluated by -frewrite-includes" part, but I have no objection to including it. The best place is probably between the /* and the #: