From 7399b5483c5b69559bbfcee27bfd415a967add85 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 26 Jul 2020 02:29:24 +0200 Subject: Rationalise compiler warning setup. --- wscript | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'wscript') diff --git a/wscript b/wscript index 72db83e2c..4fba8fb57 100644 --- a/wscript +++ b/wscript @@ -75,6 +75,7 @@ def options(opt): opt.add_option('--variant', help='build variant (swaroop-studio, swaroop-theater)', choices=['swaroop-studio', 'swaroop-theater']) opt.add_option('--use-lld', action='store_true', default=False, help='use lld linker') opt.add_option('--enable-disk', action='store_true', default=False, help='build dcpomatic2_disk tool; requires Boost process, lwext4 and nanomsg libraries') + opt.add_option('--warnings-are-errors', action='store_true', default=False, help='build with -Werror') def configure(conf): conf.load('compiler_cxx') @@ -106,16 +107,17 @@ def configure(conf): '-Wall', '-Wextra', '-Wwrite-strings', - '-Wsign-conversion', - # Remove auto_ptr warnings from libxml++-2.6 - '-Wno-deprecated-declarations', + # I tried and failed to ignore these with _Pragma + '-Wno-cast-function-type', '-Wno-ignored-qualifiers', - '-Wno-parentheses', '-D_FILE_OFFSET_BITS=64']) if conf.options.force_cpp11: conf.env.append_value('CXXFLAGS', ['-std=c++11', '-DBOOST_NO_CXX11_SCOPED_ENUMS']) + if conf.options.warnings_are_errors: + conf.env.append_value('CXXFLAGS', '-Werror') + if conf.env['CXX_NAME'] == 'gcc': gcc = conf.env['CC_VERSION'] if int(gcc[0]) >= 4 and int(gcc[1]) > 1: @@ -325,7 +327,7 @@ def configure(conf): conf.check_cc(fragment=""" #include \n int main () {\n - ssh_session s = ssh_new ();\n + ssh_new ();\n return 0;\n } """, @@ -550,7 +552,7 @@ def configure(conf): deps.append('boost_filesystem%s' % boost_lib_suffix) conf.check_cxx(fragment=""" #include \n - int main() { boost::process::child* c = new boost::process::child("foo"); }\n + int main() { new boost::process::child("foo"); }\n """, msg='Checking for boost process library', lib=deps, -- cgit v1.2.3 From 8edebbfae00f16d007f4e7062315059c8a0e8b9c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 26 Jul 2020 19:56:19 +0200 Subject: I think -Wno-cast-function-type is GCC 8 only. --- wscript | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'wscript') diff --git a/wscript b/wscript index 4fba8fb57..5ca164d51 100644 --- a/wscript +++ b/wscript @@ -108,7 +108,6 @@ def configure(conf): '-Wextra', '-Wwrite-strings', # I tried and failed to ignore these with _Pragma - '-Wno-cast-function-type', '-Wno-ignored-qualifiers', '-D_FILE_OFFSET_BITS=64']) @@ -122,6 +121,9 @@ def configure(conf): gcc = conf.env['CC_VERSION'] if int(gcc[0]) >= 4 and int(gcc[1]) > 1: conf.env.append_value('CXXFLAGS', ['-Wno-unused-result']) + if int(gcc[0]) >= 8: + # I tried and failed to ignore these with _Pragma + conf.env.append_value('CXXFLAGS', ['-Wno-cast-function-type']) if int(gcc[0]) >= 9: conf.env.append_value('CXXFLAGS', ['-Wno-deprecated-copy']) have_c11 = int(gcc[0]) >= 4 and int(gcc[1]) >= 8 and int(gcc[2]) >= 1 -- cgit v1.2.3 From 2e0cf721530a17b0190c938b04176e0315950053 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 26 Jul 2020 20:04:52 +0200 Subject: Try to remove some more default -Wno switches. --- wscript | 4 ---- 1 file changed, 4 deletions(-) (limited to 'wscript') diff --git a/wscript b/wscript index 5ca164d51..b0faa8483 100644 --- a/wscript +++ b/wscript @@ -119,13 +119,9 @@ def configure(conf): if conf.env['CXX_NAME'] == 'gcc': gcc = conf.env['CC_VERSION'] - if int(gcc[0]) >= 4 and int(gcc[1]) > 1: - conf.env.append_value('CXXFLAGS', ['-Wno-unused-result']) if int(gcc[0]) >= 8: # I tried and failed to ignore these with _Pragma conf.env.append_value('CXXFLAGS', ['-Wno-cast-function-type']) - if int(gcc[0]) >= 9: - conf.env.append_value('CXXFLAGS', ['-Wno-deprecated-copy']) have_c11 = int(gcc[0]) >= 4 and int(gcc[1]) >= 8 and int(gcc[2]) >= 1 else: have_c11 = False -- cgit v1.2.3 From 6eba051dcbb8c56e3e2efea946ce0380d17a7b33 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 26 Jul 2020 21:29:43 +0200 Subject: Various OSX warnings fixes. --- src/lib/cross.h | 5 +++-- src/lib/cross_osx.cc | 18 ++++++++++++++---- src/lib/encode_server.cc | 4 +++- src/lib/j2k_encoder.cc | 6 +++++- src/lib/json_server.cc | 4 +++- src/lib/render_text.cc | 3 +++ src/lib/util.cc | 2 ++ src/lib/wscript | 2 +- src/tools/dcpomatic.cc | 10 +++------- src/tools/dcpomatic_disk.cc | 7 ++----- src/tools/dcpomatic_disk_writer.cc | 4 ++++ src/tools/dcpomatic_kdm.cc | 6 ++---- src/tools/dcpomatic_player.cc | 9 ++------- src/tools/dcpomatic_playlist.cc | 9 ++------- src/wx/gl_video_view.cc | 2 ++ wscript | 4 ++-- 16 files changed, 53 insertions(+), 42 deletions(-) (limited to 'wscript') diff --git a/src/lib/cross.h b/src/lib/cross.h index 4d3d2b2c7..64cb2e6b8 100644 --- a/src/lib/cross.h +++ b/src/lib/cross.h @@ -40,12 +40,13 @@ class Log; struct AVIOContext; -void dcpomatic_sleep_seconds (int); -void dcpomatic_sleep_milliseconds (int); +extern void dcpomatic_sleep_seconds (int); +extern void dcpomatic_sleep_milliseconds (int); extern std::string cpu_info (); extern void run_ffprobe (boost::filesystem::path, boost::filesystem::path); extern std::list > mount_info (); extern boost::filesystem::path openssl_path (); +extern void make_foreground_application (); #ifdef DCPOMATIC_DISK extern boost::filesystem::path disk_writer_path (); #endif diff --git a/src/lib/cross_osx.cc b/src/lib/cross_osx.cc index 574cc8660..aa05df016 100644 --- a/src/lib/cross_osx.cc +++ b/src/lib/cross_osx.cc @@ -24,6 +24,7 @@ #include "dcpomatic_log.h" #include "config.h" #include "exceptions.h" +#include "warnings.h" #include #include extern "C" { @@ -35,6 +36,7 @@ extern "C" { #if BOOST_VERSION >= 106100 #include #endif +#include #include #include #include @@ -180,10 +182,7 @@ Waker::nudge () Waker::Waker () { boost::mutex::scoped_lock lm (_mutex); - /* We should use this */ - // IOPMAssertionCreateWithName (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR ("Encoding DCP"), &_assertion_id); - /* but it's not available on 10.5, so we use this */ - IOPMAssertionCreate (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &_assertion_id); + IOPMAssertionCreateWithName (kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, CFSTR ("Encoding DCP"), &_assertion_id); } Waker::~Waker () @@ -566,3 +565,14 @@ disk_write_finished () } + +void +make_foreground_application () +{ + ProcessSerialNumber serial; +DCPOMATIC_DISABLE_WARNINGS + GetCurrentProcess (&serial); +DCPOMATIC_ENABLE_WARNINGS + TransformProcessType (&serial, kProcessTransformToForegroundApplication); +} + diff --git a/src/lib/encode_server.cc b/src/lib/encode_server.cc index 61e0b09c5..c30fc8f30 100644 --- a/src/lib/encode_server.cc +++ b/src/lib/encode_server.cc @@ -239,9 +239,11 @@ EncodeServer::run () } for (int i = 0; i < _num_threads; ++i) { - boost::thread* t = _worker_threads.create_thread (bind(&EncodeServer::worker_thread, this)); #ifdef DCPOMATIC_LINUX + boost::thread* t = _worker_threads.create_thread (bind(&EncodeServer::worker_thread, this)); pthread_setname_np (t->native_handle(), "encode-server-worker"); +#else + _worker_threads.create_thread (bind(&EncodeServer::worker_thread, this)); #endif } diff --git a/src/lib/j2k_encoder.cc b/src/lib/j2k_encoder.cc index 498050073..d8d8209c9 100644 --- a/src/lib/j2k_encoder.cc +++ b/src/lib/j2k_encoder.cc @@ -389,11 +389,15 @@ J2KEncoder::servers_list_changed () if (!Config::instance()->only_servers_encode ()) { for (int i = 0; i < Config::instance()->master_encoding_threads (); ++i) { - boost::thread* t = _threads->create_thread(boost::bind(&J2KEncoder::encoder_thread, this, optional())); #ifdef DCPOMATIC_LINUX + boost::thread* t = _threads->create_thread(boost::bind(&J2KEncoder::encoder_thread, this, optional())); pthread_setname_np (t->native_handle(), "encode-worker"); #endif +#ifdef DCPOMATIC_OSX + _threads->create_thread(boost::bind(&J2KEncoder::encoder_thread, this, optional())); +#endif #ifdef DCPOMATIC_WINDOWS + boost::thread* t = _threads->create_thread(boost::bind(&J2KEncoder::encoder_thread, this, optional())); if (windows_xp) { SetThreadAffinityMask (t->native_handle(), 1 << i); } diff --git a/src/lib/json_server.cc b/src/lib/json_server.cc index 3f43a75eb..4cff27b6f 100644 --- a/src/lib/json_server.cc +++ b/src/lib/json_server.cc @@ -52,9 +52,11 @@ enum State { JSONServer::JSONServer (int port) { - thread* t = new thread (boost::bind (&JSONServer::run, this, port)); #ifdef DCPOMATIC_LINUX + thread* t = new thread (boost::bind (&JSONServer::run, this, port)); pthread_setname_np (t->native_handle(), "json-server"); +#else + new thread (boost::bind (&JSONServer::run, this, port)); #endif } diff --git a/src/lib/render_text.cc b/src/lib/render_text.cc index de33f9380..b0a958c16 100644 --- a/src/lib/render_text.cc +++ b/src/lib/render_text.cc @@ -24,10 +24,13 @@ #include "cross.h" #include "font.h" #include "dcpomatic_assert.h" +#include "warnings.h" #include #include #include +DCPOMATIC_DISABLE_WARNINGS #include +DCPOMATIC_ENABLE_WARNINGS #include #ifndef DCPOMATIC_HAVE_SHOW_IN_CAIRO_CONTEXT #include diff --git a/src/lib/util.cc b/src/lib/util.cc index 91a8ecb6e..b6ca34d22 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -66,7 +66,9 @@ extern "C" { #include #include #include +DCPOMATIC_DISABLE_WARNINGS #include +DCPOMATIC_ENABLE_WARNINGS #ifdef DCPOMATIC_WINDOWS #include #include diff --git a/src/lib/wscript b/src/lib/wscript index c2dfb55d8..0c9cddfa4 100644 --- a/src/lib/wscript +++ b/src/lib/wscript @@ -206,7 +206,7 @@ def build(bld): """ if bld.env.TARGET_OSX: - obj.framework = ['IOKit', 'Foundation', 'DiskArbitration'] + obj.framework = ['IOKit', 'Foundation', 'DiskArbitration', 'ApplicationServices'] obj.source = sources + ' version.cc' diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 9cd99a265..75b4025aa 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -98,9 +98,6 @@ #ifdef __WXMSW__ #include #endif -#ifdef __WXOSX__ -#include -#endif #include #include #include @@ -1548,10 +1545,9 @@ private: unsetenv ("UBUNTU_MENUPROXY"); #endif -#ifdef __WXOSX__ - ProcessSerialNumber serial; - GetCurrentProcess (&serial); - TransformProcessType (&serial, kProcessTransformToForegroundApplication); +#ifdef DCPOMATIC_OSX + dcpomatic_sleep_seconds (1); + make_foreground_application (); #endif dcpomatic_setup_path_encoding (); diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc index 6d8727303..55f2bd440 100644 --- a/src/tools/dcpomatic_disk.cc +++ b/src/tools/dcpomatic_disk.cc @@ -41,7 +41,6 @@ #include #endif #ifdef DCPOMATIC_OSX -#include #include #endif @@ -317,10 +316,8 @@ public: unsetenv ("UBUNTU_MENUPROXY"); #endif -#ifdef __WXOSX__ - ProcessSerialNumber serial; - GetCurrentProcess (&serial); - TransformProcessType (&serial, kProcessTransformToForegroundApplication); +#ifdef DCPOMATIC_OSX + make_foreground_application (); #endif dcpomatic_setup_path_encoding (); diff --git a/src/tools/dcpomatic_disk_writer.cc b/src/tools/dcpomatic_disk_writer.cc index 66d38ec19..1e6d10fbf 100644 --- a/src/tools/dcpomatic_disk_writer.cc +++ b/src/tools/dcpomatic_disk_writer.cc @@ -27,6 +27,7 @@ #include "lib/file_log.h" #include "lib/dcpomatic_log.h" #include "lib/nanomsg.h" +#include "lib/warnings.h" extern "C" { #include #include @@ -66,7 +67,10 @@ extern "C" { } #endif +DCPOMATIC_DISABLE_WARNINGS #include +DCPOMATIC_ENABLE_WARNINGS + #include #include #include diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 117e756c7..84573797e 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -718,10 +718,8 @@ private: unsetenv ("UBUNTU_MENUPROXY"); #endif -#ifdef __WXOSX__ - ProcessSerialNumber serial; - GetCurrentProcess (&serial); - TransformProcessType (&serial, kProcessTransformToForegroundApplication); +#ifdef DCPOMATIC_OSX + make_foreground_application (); #endif dcpomatic_setup_path_encoding (); diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 67a06aec4..17f652625 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -73,9 +73,6 @@ #ifdef __WXGTK__ #include #endif -#ifdef __WXOSX__ -#include -#endif #include #include #include @@ -1156,10 +1153,8 @@ private: unsetenv ("UBUNTU_MENUPROXY"); #endif -#ifdef __WXOSX__ - ProcessSerialNumber serial; - GetCurrentProcess (&serial); - TransformProcessType (&serial, kProcessTransformToForegroundApplication); +#ifdef DCPOMATIC_OSX + make_foreground_application (); #endif dcpomatic_setup_path_encoding (); diff --git a/src/tools/dcpomatic_playlist.cc b/src/tools/dcpomatic_playlist.cc index 04950028a..b2b5c458a 100644 --- a/src/tools/dcpomatic_playlist.cc +++ b/src/tools/dcpomatic_playlist.cc @@ -36,9 +36,6 @@ #include #include #include -#ifdef __WXOSX__ -#include -#endif #include using std::exception; @@ -585,10 +582,8 @@ private: unsetenv ("UBUNTU_MENUPROXY"); #endif -#ifdef __WXOSX__ - ProcessSerialNumber serial; - GetCurrentProcess (&serial); - TransformProcessType (&serial, kProcessTransformToForegroundApplication); +#ifdef DCPOMATIC_OSX + make_foreground_application (); #endif dcpomatic_setup_path_encoding (); diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc index 786cee84a..a87249faf 100644 --- a/src/wx/gl_video_view.cc +++ b/src/wx/gl_video_view.cc @@ -180,7 +180,9 @@ GLVideoView::draw (Position inter_position, dcp::Size inter_size) glMatrixMode (GL_PROJECTION); glLoadIdentity (); +DCPOMATIC_DISABLE_WARNINGS gluOrtho2D (0, canvas_size.GetWidth(), canvas_size.GetHeight(), 0); +DCPOMATIC_ENABLE_WARNINGS check_gl_error ("gluOrtho2d"); glMatrixMode (GL_MODELVIEW); glLoadIdentity (); diff --git a/wscript b/wscript index b0faa8483..b1e2096d4 100644 --- a/wscript +++ b/wscript @@ -322,7 +322,7 @@ def configure(conf): if conf.options.workaround_gssapi: conf.env.LIB_SSH = ['gssapi_krb5'] else: - conf.check_cc(fragment=""" + conf.check_cxx(fragment=""" #include \n int main () {\n ssh_new ();\n @@ -501,7 +501,7 @@ def configure(conf): conf.check_cxx(fragment=""" #include \n - int main() { boost::thread t (); }\n + int main() { boost::thread t; }\n """, msg='Checking for boost threading library', libpath='/usr/local/lib', -- cgit v1.2.3 From f15a469c036587a74d93fa14506eac87502d2b4c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 27 Jul 2020 10:24:57 +0200 Subject: Test: remove some more Wno flags. --- wscript | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'wscript') diff --git a/wscript b/wscript index b1e2096d4..b9e7d6a64 100644 --- a/wscript +++ b/wscript @@ -203,11 +203,8 @@ def configure(conf): # OSX if conf.env.TARGET_OSX: - conf.env.append_value('CXXFLAGS', ['-DDCPOMATIC_OSX', '-Wno-unused-function', '-Wno-unused-parameter', '-Wno-unused-local-typedef', '-Wno-potentially-evaluated-expression']) + conf.env.append_value('CXXFLAGS', ['-DDCPOMATIC_OSX']) conf.env.append_value('LINKFLAGS', '-headerpad_max_install_names') - else: - # Avoid the endless warnings about _t uninitialized in optional<> - conf.env.append_value('CXXFLAGS', '-Wno-maybe-uninitialized') # # Dependencies. -- cgit v1.2.3 From 99c1d1f247343b884af0b51389311484ed265d3b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 27 Jul 2020 11:05:08 +0200 Subject: Fix some unused variable warnings on macOS. --- src/lib/cross_osx.cc | 4 ++-- src/tools/dcpomatic_disk.cc | 3 +++ src/tools/dcpomatic_disk_writer.cc | 2 +- wscript | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) (limited to 'wscript') diff --git a/src/lib/cross_osx.cc b/src/lib/cross_osx.cc index aa05df016..e91d3df16 100644 --- a/src/lib/cross_osx.cc +++ b/src/lib/cross_osx.cc @@ -245,7 +245,7 @@ home_directory () } string -command_and_read (string cmd) +command_and_read (string) { return ""; } @@ -515,7 +515,7 @@ config_path () } -void done_callback(DADiskRef disk, DADissenterRef dissenter, void* context) +void done_callback(DADiskRef, DADissenterRef dissenter, void* context) { LOG_DISK_NC("Unmount finished"); bool* success = reinterpret_cast (context); diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc index 55f2bd440..b94d4bf94 100644 --- a/src/tools/dcpomatic_disk.cc +++ b/src/tools/dcpomatic_disk.cc @@ -35,8 +35,11 @@ #include "lib/job_manager.h" #include "lib/disk_writer_messages.h" #include "lib/version.h" +#include "lib/warnings.h" #include +DCPOMATIC_DISABLE_WARNINGS #include +DCPOMATIC_ENABLE_WARNINGS #ifdef DCPOMATIC_WINDOWS #include #endif diff --git a/src/tools/dcpomatic_disk_writer.cc b/src/tools/dcpomatic_disk_writer.cc index 1e6d10fbf..2c3753e57 100644 --- a/src/tools/dcpomatic_disk_writer.cc +++ b/src/tools/dcpomatic_disk_writer.cc @@ -569,7 +569,7 @@ main () /* I *think* this confumes the notifyd event that we used to start the process, so we only * get started once per notification. */ - xpc_set_event_stream_handler("com.apple.notifyd.matching", DISPATCH_TARGET_QUEUE_DEFAULT, ^(xpc_object_t event) {}); + xpc_set_event_stream_handler("com.apple.notifyd.matching", DISPATCH_TARGET_QUEUE_DEFAULT, ^(xpc_object_t) {}); #endif try { diff --git a/wscript b/wscript index b9e7d6a64..a333f95d8 100644 --- a/wscript +++ b/wscript @@ -549,6 +549,7 @@ def configure(conf): #include \n int main() { new boost::process::child("foo"); }\n """, + cxxflags='-Wno-unused-parameter', msg='Checking for boost process library', lib=deps, uselib_store='BOOST_PROCESS') -- cgit v1.2.3 From 5d440e1133fc68dfffeaf53cf934b996dae811c7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 27 Jul 2020 19:42:46 +0200 Subject: Work around a GCC bug related to Wmaybe-initialized. --- wscript | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'wscript') diff --git a/wscript b/wscript index a333f95d8..f874758dd 100644 --- a/wscript +++ b/wscript @@ -122,6 +122,11 @@ def configure(conf): if int(gcc[0]) >= 8: # I tried and failed to ignore these with _Pragma conf.env.append_value('CXXFLAGS', ['-Wno-cast-function-type']) + elif int(gcc[0]) == 7: + # There appears to be a GCC bug which lingered from major versions 5--7 and which + # flags up these warnings all over the place in boost::optional. + # These seems to be the only practical way to hide it + conf.env.append_value('CXXFLAGS', ['-Wno-maybe-uninitialized']) have_c11 = int(gcc[0]) >= 4 and int(gcc[1]) >= 8 and int(gcc[2]) >= 1 else: have_c11 = False -- cgit v1.2.3