From 9809ce38e9f79b4e9a0b1ec1c076cce0beee1e98 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 19 Dec 2017 09:09:52 -0800 Subject: Use appropriate preprocessor guards to allow building without exceptions --- include/grpc/impl/codegen/port_platform.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include/grpc/impl/codegen/port_platform.h') diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index e6bee73ef1..becb16b5b8 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -477,6 +477,21 @@ typedef unsigned __int64 uint64_t; #endif /* GPR_ATTRIBUTE_NO_TSAN (2) */ #endif /* GPR_ATTRIBUTE_NO_TSAN (1) */ +/* 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 +#define GRPC_ALLOW_EXCEPTIONS 1 +#else +#ifdef __EXCEPTIONS +#define GRPC_ALLOW_EXCEPTIONS 1 +#else +#define GRPC_ALLOW_EXCEPTIONS 0 +#endif +#endif +#endif + #ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS #endif -- cgit v1.2.3 From ab0065478419c785e21012fbbeb2c28b5a37d3b3 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 19 Dec 2017 10:17:11 -0800 Subject: Tag new #else and #endif blocks with comments --- include/grpc++/impl/codegen/method_handler_impl.h | 4 ++-- include/grpc/impl/codegen/port_platform.h | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'include/grpc/impl/codegen/port_platform.h') diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h index 41c287231f..ed6c146e6c 100644 --- a/include/grpc++/impl/codegen/method_handler_impl.h +++ b/include/grpc++/impl/codegen/method_handler_impl.h @@ -45,9 +45,9 @@ Status CatchingFunctionHandler(Callable&& handler) { } catch (...) { return Status(StatusCode::UNKNOWN, "Exception in method handler"); } -#else +#else // GRPC_ALLOW_EXCEPTIONS return handler(); -#endif +#endif // GRPC_ALLOW_EXCEPTIONS } /// A wrapper class of an application provided rpc method handler. diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index becb16b5b8..a03c31dc9d 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -483,14 +483,14 @@ typedef unsigned __int64 uint64_t; * 0 on non-Windows platforms unless the compiler defines __EXCEPTIONS */ #ifdef GPR_WINDOWS #define GRPC_ALLOW_EXCEPTIONS 1 -#else +#else /* GPR_WINDOWS */ #ifdef __EXCEPTIONS #define GRPC_ALLOW_EXCEPTIONS 1 -#else +#else /* __EXCEPTIONS */ #define GRPC_ALLOW_EXCEPTIONS 0 -#endif -#endif -#endif +#endif /* __EXCEPTIONS */ +#endif /* __GPR_WINDOWS */ +#endif /* GRPC_ALLOW_EXCEPTIONS */ #ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS -- cgit v1.2.3