[PATCH] D130800: [clang][Headers] Avoid compiler warnings in builtin headers

Dominic Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 2 15:20:21 PDT 2022


ddcc added inline comments.


================
Comment at: clang/lib/Headers/__clang_hip_cmath.h:381
 // decltype is only available in C++11 and above.
-#if __cplusplus >= 201103L
+#if defined(__cplusplus) && __cplusplus >= 201103L
 // __hip_promote
----------------
tra wrote:
> HIP headers are also not expected to compile w/o C++ and we may want a `#error`here, too. 
> 
> Actually, I'm not even sure if we shopuld/need to add `#if defined(__cplusplus)`in files that are clearly C++ -- undefined macro warning will be the least of one's worries if they attempt to compile it w/o C++.
> 
> Perhaps it would make sense to limit these changes to the headers intended to be used from both C and C++? Both CUDA and HIP are expected to never be included from a non-C++ compilation and will never trigger the undefined macro warning on `__cplusplus`.
> 
> @yaxunl - FYI.
Sure, I'm fine with leaving those headers alone since I'm not familiar with them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130800



More information about the cfe-commits mailing list