From c7f0b10ce1a5250c485bd7940fcaf19c0e65421e Mon Sep 17 00:00:00 2001 From: "Mark A. Tsuchida" Date: Wed, 4 Sep 2024 17:12:40 -0500 Subject: [PATCH] MMDevice: Allow compilation with C++17 - Remove pointless `throw ()` from two functions. - Wrap remaining dynamic exception specifications (2 occurrences) in macro, which expands to nothing unless read by SWIG. - Removed the warning suppressions related to dynamic exception specifications. - Confirmed, using japicmp, that the MMCoreJ API did not change (tested with SWIG 3, Linux). - There is no C++ MMDevice ABI change because dynamic exception specifications are not part of the ABI (so no increment of device interface version). --- MMDevice/DeviceBase.h | 4 ++-- MMDevice/ImageMetadata.h | 29 ++++++++--------------------- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/MMDevice/DeviceBase.h b/MMDevice/DeviceBase.h index 883b7e34b..84cef7177 100644 --- a/MMDevice/DeviceBase.h +++ b/MMDevice/DeviceBase.h @@ -1562,7 +1562,7 @@ class CCameraBase : public CDeviceBase virtual long GetNumberOfImages() {return thd_->GetNumberOfImages();} // called from the thread function before exit - virtual void OnThreadExiting() throw() + virtual void OnThreadExiting() { try { @@ -1668,7 +1668,7 @@ class CCameraBase : public CDeviceBase void UpdateActualDuration() {actualDuration_ = camera_->GetCurrentMMTime() - startTime_;} private: - virtual int svc(void) throw() + virtual int svc() { int ret=DEVICE_ERR; try diff --git a/MMDevice/ImageMetadata.h b/MMDevice/ImageMetadata.h index 98f5c8a64..212d7b084 100644 --- a/MMDevice/ImageMetadata.h +++ b/MMDevice/ImageMetadata.h @@ -22,17 +22,6 @@ #pragma once -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4290) // 'C++ exception specification ignored' -#endif - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC diagnostic push -// 'dynamic exception specifications are deprecated in C++11 [-Wdeprecated]' -#pragma GCC diagnostic ignored "-Wdeprecated" -#endif - #include "MMDeviceConstants.h" #include @@ -42,6 +31,12 @@ #include #include +#ifdef SWIG +#define MMDEVICE_LEGACY_THROW(ex) throw (ex) +#else +#define MMDEVICE_LEGACY_THROW(ex) +#endif + /////////////////////////////////////////////////////////////////////////////// // MetadataError // ------------- @@ -326,14 +321,14 @@ class Metadata return false; } - MetadataSingleTag GetSingleTag(const char* key) const throw (MetadataKeyError) + MetadataSingleTag GetSingleTag(const char* key) const MMDEVICE_LEGACY_THROW(MetadataKeyError) { MetadataTag* tag = FindTag(key); const MetadataSingleTag* stag = tag->ToSingleTag(); return *stag; } - MetadataArrayTag GetArrayTag(const char* key) const throw (MetadataKeyError) + MetadataArrayTag GetArrayTag(const char* key) const MMDEVICE_LEGACY_THROW(MetadataKeyError) { MetadataTag* tag = FindTag(key); const MetadataArrayTag* atag = tag->ToArrayTag(); @@ -499,11 +494,3 @@ class Metadata typedef std::map::iterator TagIter; typedef std::map::const_iterator TagConstIter; }; - -#if defined(__GNUC__) && !defined(__clang__) -#pragma GCC diagnostic pop -#endif - -#ifdef _MSC_VER -#pragma warning(pop) -#endif