瀏覽代碼

Make PROTOBUF_USE_EXCEPTIONS configurable from CPPFLAGS.

liujisi@google.com 13 年之前
父節點
當前提交
e719489061
共有 2 個文件被更改,包括 11 次插入6 次删除
  1. 2 2
      src/google/protobuf/stubs/common.cc
  2. 9 4
      src/google/protobuf/stubs/common.h

+ 2 - 2
src/google/protobuf/stubs/common.cc

@@ -191,7 +191,7 @@ void LogMessage::Finish() {
   }
 
   if (level_ == LOGLEVEL_FATAL) {
-#ifdef PROTOBUF_USE_EXCEPTIONS
+#if PROTOBUF_USE_EXCEPTIONS
     throw FatalException(filename_, line_, message_);
 #else
     abort();
@@ -383,7 +383,7 @@ void ShutdownProtobufLibrary() {
   internal::shutdown_functions_mutex = NULL;
 }
 
-#ifdef PROTOBUF_USE_EXCEPTIONS
+#if PROTOBUF_USE_EXCEPTIONS
 FatalException::~FatalException() throw() {}
 
 const char* FatalException::what() const throw() {

+ 9 - 4
src/google/protobuf/stubs/common.h

@@ -48,12 +48,17 @@
 #include <stdint.h>
 #endif
 
+#ifndef PROTOBUF_USE_EXCEPTIONS
 #if defined(_MSC_VER) && defined(_CPPUNWIND)
-  #define PROTOBUF_USE_EXCEPTIONS
+  #define PROTOBUF_USE_EXCEPTIONS 1
 #elif defined(__EXCEPTIONS)
-  #define PROTOBUF_USE_EXCEPTIONS
+  #define PROTOBUF_USE_EXCEPTIONS 1
+#else
+  #define PROTOBUF_USE_EXCEPTIONS 0
+#endif
 #endif
-#ifdef PROTOBUF_USE_EXCEPTIONS
+
+#if PROTOBUF_USE_EXCEPTIONS
 #include <exception>
 #endif
 
@@ -1188,7 +1193,7 @@ LIBPROTOBUF_EXPORT void OnShutdown(void (*func)());
 
 }  // namespace internal
 
-#ifdef PROTOBUF_USE_EXCEPTIONS
+#if PROTOBUF_USE_EXCEPTIONS
 class FatalException : public std::exception {
  public:
   FatalException(const char* filename, int line, const std::string& message)