From 036cdc661647f7c24c95b1c53a1a684b3537fa50 Mon Sep 17 00:00:00 2001 From: Loo Rong Jie Date: Sat, 15 Jun 2019 22:19:03 +0800 Subject: [PATCH] Properly detect C++ exception for MSVC Inspired from protobuf https://github.com/protocolbuffers/protobuf/blob/77f03d932a35e8aa0a98c0c728ad3f5aacfe30ce/src/google/protobuf/stubs/common.h#L50 --- include/grpc/impl/codegen/port_platform.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index d7294d59d41..591385eb705 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -618,10 +618,14 @@ typedef unsigned __int64 uint64_t; /* GRPC_ALLOW_EXCEPTIONS should be 0 or 1 if exceptions are allowed or not */ #ifndef GRPC_ALLOW_EXCEPTIONS -/* If not already set, set to 1 on Windows (style guide standard) but to - * 0 on non-Windows platforms unless the compiler defines __EXCEPTIONS */ #ifdef GPR_WINDOWS +#if defined(_MSC_VER) && defined(_CPPUNWIND) #define GRPC_ALLOW_EXCEPTIONS 1 +#elif defined(__EXCEPTIONS) +#define GRPC_ALLOW_EXCEPTIONS 1 +#else +#define GRPC_ALLOW_EXCEPTIONS 0 +#endif #else /* GPR_WINDOWS */ #ifdef __EXCEPTIONS #define GRPC_ALLOW_EXCEPTIONS 1