From 8aa7e8b7a99aa8dfbfbab2944dcdccffeed10172 Mon Sep 17 00:00:00 2001 From: Scott Wolchok Date: Fri, 13 Jun 2025 13:19:03 -0700 Subject: [PATCH] Define ET_HAS_EXCEPTIONS macro Pull Request resolved: https://github.com/pytorch/executorch/pull/11603 To support passing ET_USE_PYTORCH_HEADERS only when exceptions are enabled. ghstack-source-id: 290334875 @exported-using-ghexport Differential Revision: [D76470039](https://our.internmc.facebook.com/intern/diff/D76470039/) --- runtime/platform/compiler.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/runtime/platform/compiler.h b/runtime/platform/compiler.h index 7467d5c1e04..864b76e2050 100644 --- a/runtime/platform/compiler.h +++ b/runtime/platform/compiler.h @@ -171,6 +171,14 @@ using ssize_t = ptrdiff_t; #endif +#ifdef __EXCEPTIONS +#define ET_HAS_EXCEPTIONS 1 +#elif defined(_HAS_EXCEPTIONS) && _HAS_EXCEPTIONS +#define ET_HAS_EXCEPTIONS 1 +#else +#define ET_HAS_EXCEPTIONS 0 +#endif + // DEPRECATED: Use the non-underscore-prefixed versions instead. // TODO(T199005537): Remove these once all users have stopped using them. #define __ET_DEPRECATED ET_DEPRECATED