JonChesterfield added a comment.

Logic doesn't look quite right to me. If the compiler supports has_include, but 
neither of those headers exist, we fall through to main() which won't compile.

How about:

  #if defined(__has_include)
    #if __has_include("hsa.h")
      #define HSA_FOUND 1 // name tbd
      #include "hsa.h"
    #elif __has_include("hsa/hsa.h")
      #define HSA_FOUND 1
      #include "hsa/hsa.h"
    #else
      #define HSA_FOUND 0
    #endif
  #else
    #define HSA_FOUND 0
  #endif
  
  
  #if !HSA_FOUND
  int main() { return 1; }
  #else
  // all the current stuff
  #endif

That takes the approach that missing __has_include is a bad sign and 
immediately gives up. As far as I can tell it was introduced ~ 10 years ago, 
and was more recently added to c++17 
(https://en.cppreference.com/w/cpp/preprocessor/include, which uses a similar 
pattern to the above in terms of booleans). Seems to be present in gcc, clang, 
msvc and we have a safe fallback if it isn't.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102067/new/

https://reviews.llvm.org/D102067

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to