From 121458fbab17bd9cc960928d644a99e25891aa45 Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Sun, 9 Aug 2015 21:15:16 +0200 Subject: -Fix: C++11 forbids throwing exceptions in destructors by default, but the script API relies on them. Explicitly allow exceptions. --- src/core/alloc_type.hpp | 2 +- src/misc/countedptr.hpp | 2 +- src/network/core/core.h | 2 +- src/network/core/tcp_http.h | 2 +- src/network/network_content.h | 2 +- src/newgrf_config.h | 2 +- src/newgrf_spritegroup.h | 2 +- src/stdafx.h | 10 ++++++++++ src/strings_func.h | 2 +- 9 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/core/alloc_type.hpp b/src/core/alloc_type.hpp index 9c25cc9..a50d092 100644 --- a/src/core/alloc_type.hpp +++ b/src/core/alloc_type.hpp @@ -151,7 +151,7 @@ class ZeroedMemoryAllocator { public: ZeroedMemoryAllocator() {} - virtual ~ZeroedMemoryAllocator() {} + virtual ~ZeroedMemoryAllocator() NOEXCEPT(false) {} /** * Memory allocator for a single class instance. diff --git a/src/misc/countedptr.hpp b/src/misc/countedptr.hpp index e7b28a6..a72fb4a 100644 --- a/src/misc/countedptr.hpp +++ b/src/misc/countedptr.hpp @@ -210,7 +210,7 @@ struct SimpleCountedObject { : m_ref_cnt(0) {} - virtual ~SimpleCountedObject() + virtual ~SimpleCountedObject() NOEXCEPT(false) {} virtual int32 AddRef(); diff --git a/src/network/core/core.h b/src/network/core/core.h index a250dbb..73947ba 100644 --- a/src/network/core/core.h +++ b/src/network/core/core.h @@ -49,7 +49,7 @@ class NetworkSocketHandler { NetworkSocketHandler() { this->has_quit = false; } /** Close the socket when destructing the socket handler */ - virtual ~NetworkSocketHandler() { this->Close(); } + virtual ~NetworkSocketHandler() NOEXCEPT(false) { this->Close(); } /** Really close the socket */ virtual void Close() {} diff --git a/src/network/core/tcp_http.h b/src/network/core/tcp_http.h index 36520f1..893fbeb 100644 --- a/src/network/core/tcp_http.h +++ b/src/network/core/tcp_http.h @@ -35,7 +35,7 @@ struct HTTPCallback { virtual void OnReceiveData(const char *data, size_t length) = 0; /** Silentium */ - virtual ~HTTPCallback() {} + virtual ~HTTPCallback() NOEXCEPT(false) {} }; /** Base socket handler for HTTP traffic. */ diff --git a/src/network/network_content.h b/src/network/network_content.h index ce369cd..7b46a72 100644 --- a/src/network/network_content.h +++ b/src/network/network_content.h @@ -60,7 +60,7 @@ struct ContentCallback { virtual void OnDownloadComplete(ContentID cid) {} /** Silentium */ - virtual ~ContentCallback() {} + virtual ~ContentCallback() NOEXCEPT(false) {} }; /** diff --git a/src/newgrf_config.h b/src/newgrf_config.h index e19d8d6..85a6584 100644 --- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -208,7 +208,7 @@ extern GRFConfig *_grfconfig_static; ///< First item in list of static GRF set /** Callback for NewGRF scanning. */ struct NewGRFScanCallback { /** Make sure the right destructor gets called. */ - virtual ~NewGRFScanCallback() {} + virtual ~NewGRFScanCallback() NOEXCEPT(false) {} /** Called whenever the NewGRF scan completed. */ virtual void OnNewGRFsScanned() = 0; }; diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index 0a7705d..c12fbf0 100644 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -62,7 +62,7 @@ struct SpriteGroup : SpriteGroupPool::PoolItem<&_spritegroup_pool> { virtual const SpriteGroup *Resolve(ResolverObject &object) const { return this; }; public: - virtual ~SpriteGroup() {} + virtual ~SpriteGroup() NOEXCEPT(false) {} SpriteGroupType type; diff --git a/src/stdafx.h b/src/stdafx.h index 4616212..5193ab4 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -156,6 +156,9 @@ #else #define FINAL #endif + #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && (defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)) + #define NOEXCEPT(x) noexcept(x) + #endif #endif /* __GNUC__ */ #if defined(__WATCOMC__) @@ -274,6 +277,9 @@ #define S_ISDIR(mode) (mode & S_IFDIR) #define S_ISREG(mode) (mode & S_IFREG) + #if _MSC_VER >= 1900 + #define NOEXCEPT(x) noexcept(x) + #endif #endif /* defined(_MSC_VER) */ #if defined(DOS) @@ -516,4 +522,8 @@ static inline void free(const void *ptr) #define IGNORE_UNINITIALIZED_WARNING_STOP #endif +#ifndef NOEXCEPT + #define NOEXCEPT(x) +#endif + #endif /* STDAFX_H */ diff --git a/src/strings_func.h b/src/strings_func.h index 2c7809d..e326e52 100644 --- a/src/strings_func.h +++ b/src/strings_func.h @@ -203,7 +203,7 @@ int CDECL StringIDSorter(const StringID *a, const StringID *b); class MissingGlyphSearcher { public: /** Make sure everything gets destructed right. */ - virtual ~MissingGlyphSearcher() {} + virtual ~MissingGlyphSearcher() NOEXCEPT(false) {} /** * Get the next string to search through. -- 2.4.5