From 1cd341f8350ed1c54c5089957bf43f8e12c59b9f Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 11 May 2021 11:17:56 +0800 Subject: cairomm/exception.h: Export Cairo::logic_error selectively Since this class derives std::logic_error, don't export the class as a whole but instead export its member methods as necessary on Windows. This will make the compiled DLL to not be locked in a single compiler/STL version, and will remove the compiler warnings C4251, C4273 and C4275 on Visual Studio. --- cairomm/exception.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cairomm/exception.h b/cairomm/exception.h index b60c190..bffabed 100644 --- a/cairomm/exception.h +++ b/cairomm/exception.h @@ -34,14 +34,14 @@ namespace Cairo /** */ -class CAIROMM_API logic_error: public std::logic_error +class logic_error: public std::logic_error { public: - explicit logic_error(ErrorStatus status); - ~logic_error() noexcept override; + CAIROMM_API explicit logic_error(ErrorStatus status); + CAIROMM_API ~logic_error() noexcept override; //virtual const char* what() const noexcept; - ErrorStatus get_status_code() const; + CAIROMM_API ErrorStatus get_status_code() const; private: ErrorStatus m_status; -- cgit v1.2.3 From cc4bd55dcb1d4ade77a01e259fff5060a69c8b85 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 11 May 2021 11:21:15 +0800 Subject: MSVC_NMake/config-msvc.mak: Clean up compiler flags Since we eliminated the C4251, C4273 and C4275 warnings, don't ignore them along with C4530, since we are now using /EHsc. This will make the compiler flags a bit cleaner --- MSVC_NMake/config-msvc.mak | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MSVC_NMake/config-msvc.mak b/MSVC_NMake/config-msvc.mak index 65b343a..2b96c39 100644 --- a/MSVC_NMake/config-msvc.mak +++ b/MSVC_NMake/config-msvc.mak @@ -22,8 +22,7 @@ CAIROMM_BASE_CFLAGS = \ /D_CRT_NONSTDC_NO_WARNINGS \ /I.. /I.\cairomm \ /D_USE_MATH_DEFINES \ - /EHsc \ - /wd4251 /wd4275 /wd4530 + /EHsc !if $(VSVER) > 12 CAIROMM_BASE_CFLAGS = $(CAIROMM_BASE_CFLAGS) /utf-8 -- cgit v1.2.3 From a5795244b493aa4c12db51fbe316bba738cfe616 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 11 May 2021 11:22:49 +0800 Subject: meson: Reorganize warnings on Visual Studio builds We can now drop the ignores for warnings C4251, C4273 and C4275 along with C4530, since our code and compiler flags should now make us free of them, since we use /EHsc to build our code and we are clean of classes that we export as a whole that derives from std::xxx classes. Ignore warning C4800, and warning C4127 in the examples, since these warnings are really spurious and safe to ignore as a whole. --- examples/meson.build | 8 +++++++- meson.build | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/meson.build b/examples/meson.build index adc0e68..bc948b6 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -13,6 +13,12 @@ examples = [ [['text'], 'user-font', ['user-font.cc']], ] +if is_msvc + ex_disabled_warnings = cpp_compiler.get_supported_arguments('/wd4127') +else + ex_disabled_warnings = [] +endif + foreach ex : examples dir = '' foreach dir_part : ex[0] @@ -25,7 +31,7 @@ foreach ex : examples endforeach executable(ex_name, ex_sources, - cpp_args: '-DCAIROMM_DISABLE_DEPRECATED', + cpp_args: [ '-DCAIROMM_DISABLE_DEPRECATED' ] + ex_disabled_warnings, dependencies: cairomm_own_dep, implicit_include_directories: false, gui_app: false, diff --git a/meson.build b/meson.build index 028a09c..b5d58e7 100644 --- a/meson.build +++ b/meson.build @@ -214,7 +214,7 @@ msvc14x_toolset_ver = '' # MSVC: Ignore warnings that aren't really harmful, but make those # that should not be overlooked stand out. if is_msvc - foreach wd : ['/FImsvc_recommended_pragmas.h', '/wd4251', '/wd4267', '/wd4275', '/wd4530', '/utf-8'] + foreach wd : ['/FImsvc_recommended_pragmas.h', '/wd4267', '/wd4800', '/utf-8'] disabled_warning = cpp_compiler.get_supported_arguments(wd) add_project_arguments(disabled_warning, language: 'cpp') endforeach -- cgit v1.2.3