From 7c6c027d33b06eb706f93e3d178a2305d7bcfd56 Mon Sep 17 00:00:00 2001 From: Chih-Hsuan Yen Date: Thu, 24 Oct 2019 23:23:02 +0800 Subject: [PATCH] Fix building on Mac OS X 10.11 or older * Add a missing include in src/core/Alloc.cpp On Mac OS X 10.11 with Xcode 8.2.1, building fails with /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_security_KeePassXC/KeePassXC-devel/work/keepassxc-f726d7501ff7e8a66ae974719042f23010716595/src/core/Alloc.cpp:44:10: error: no type named 'free' in namespace 'std' std::free(ptr); ~~~~~^ Per [1], std::free() needs #include . That file is included indirectly on newer systems. * Avoid const Signature object in src/keeshare/ShareExport.cpp After the above issue is resolved, building fails at /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_security_KeePassXC/KeePassXC-devel/work/keepassxc-f726d7501ff7e8a66ae974719042f23010716595/src/keeshare/ShareExport.cpp:152:29: error: default initialization of an object of const type 'const Signature' without a user-provided default constructor const Signature signer; ^ Apparently this is related to C++ defect 253 [2]. From the code, creating a Signature is not needed as all methods in Signature are static, so just call the method. [1] https://en.cppreference.com/w/cpp/memory/c/free [2] https://stackoverflow.com/a/47368753 --- src/core/Alloc.cpp | 1 + src/keeshare/ShareExport.cpp | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/Alloc.cpp b/src/core/Alloc.cpp index a076b70a9..967b4e3ef 100644 --- a/src/core/Alloc.cpp +++ b/src/core/Alloc.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #if defined(Q_OS_MACOS) #include diff --git a/src/keeshare/ShareExport.cpp b/src/keeshare/ShareExport.cpp index 500d8d3f9..c17c5052c 100644 --- a/src/keeshare/ShareExport.cpp +++ b/src/keeshare/ShareExport.cpp @@ -149,8 +149,7 @@ namespace KeeShareSettings::Sign sign; auto sshKey = own.key.sshKey(); sshKey.openKey(QString()); - const Signature signer; - sign.signature = signer.create(bytes, sshKey); + sign.signature = Signature::create(bytes, sshKey); sign.certificate = own.certificate; stream << KeeShareSettings::Sign::serialize(sign); stream.flush();