From 60edf3eea00b57c2049d5979a1ab598ac345d7b0 Mon Sep 17 00:00:00 2001 From: Alexandre Courbot Date: Thu, 8 Sep 2016 15:15:59 +0900 Subject: [PATCH 1/3] wscript: check C libraries using the C compiler On recent g++ versions, the configure stage will fail when checking for the sqrt function with the following compiler error: ../test.cpp:11:16: error: overloaded function with no contextual type information This is due to the fact that 'sqrt' also exists in the std namespace. As the functions tested are C functions, use the C compiler to check for their presence in order to avoid these issues. --- wscript | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wscript b/wscript index cab62a32..54370fb2 100644 --- a/wscript +++ b/wscript @@ -82,17 +82,17 @@ def configure(ctx): # Check required headers req_headers = ['stdlib.h', 'string.h', 'unistd.h', 'stdint.h', 'stdio.h', 'jpeglib.h'] for header in req_headers: - ctx.check_cxx(header_name = header, auto_add_header_name = True, mandatory = True) + ctx.check_cc(header_name = header, auto_add_header_name = True, mandatory = True) # Check for required libs req_libs = [('m', 'm'), ('jpeg', 'jpeg')] for (lib, uselib) in req_libs: - ctx.check_cxx(lib = lib, uselib_store = uselib) + ctx.check_cc(lib = lib, uselib_store = uselib) # Check required functions req_funcs = [('memset', 'string.h', []) ,('sqrt', 'math.h', ['m'])] for func, header, uselib in req_funcs: - ctx.check_cxx(function_name = func, header_name = header, + ctx.check_cc(function_name = func, header_name = header, uselib = uselib, mandatory = True) # Check for a supported version of libpng From 805023bce02816ec19c4e5980f6306c44da81087 Mon Sep 17 00:00:00 2001 From: Alexandre Courbot Date: Thu, 8 Sep 2016 15:21:31 +0900 Subject: [PATCH 2/3] Do not use deprecated std::auto_ptr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit auto_ptr has been deprecated in recent C++ revisions. As glmark2 is compiled with -Werror by default, this results in compilation failures with recent g++ versions, e.g: ../src/model.cpp:684:16: error: ‘template class std::auto_ptr’ is deprecated [-Werror=deprecated-declarations] Replace the use of auto_ptr with unique_ptr throughout the code to fix this. --- src/image-reader.cpp | 2 +- src/libmatrix/shader-source.cc | 2 +- src/model.cpp | 4 ++-- src/scene-jellyfish.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/image-reader.cpp b/src/image-reader.cpp index 50e5c33a..a6e75f5b 100644 --- a/src/image-reader.cpp +++ b/src/image-reader.cpp @@ -120,7 +120,7 @@ PNGReader::init(const std::string& filename) Log::debug("Reading PNG file %s\n", filename.c_str()); - const std::auto_ptr is_ptr(Util::get_resource(filename)); + const std::unique_ptr is_ptr(Util::get_resource(filename)); if (!(*is_ptr)) { Log::error("Cannot open file %s!\n", filename.c_str()); return false; diff --git a/src/libmatrix/shader-source.cc b/src/libmatrix/shader-source.cc index d34c8a02..32df82b2 100644 --- a/src/libmatrix/shader-source.cc +++ b/src/libmatrix/shader-source.cc @@ -34,7 +34,7 @@ ShaderSource::default_precision_(ShaderSource::ShaderTypeUnknown + 1); bool ShaderSource::load_file(const std::string& filename, std::string& str) { - std::auto_ptr is_ptr(Util::get_resource(filename)); + std::unique_ptr is_ptr(Util::get_resource(filename)); std::istream& inputFile(*is_ptr); if (!inputFile) diff --git a/src/model.cpp b/src/model.cpp index e38296ec..4bb6a200 100644 --- a/src/model.cpp +++ b/src/model.cpp @@ -361,7 +361,7 @@ Model::load_3ds(const std::string &filename) Log::debug("Loading model from 3ds file '%s'\n", filename.c_str()); - const std::auto_ptr input_file_ptr(Util::get_resource(filename)); + const std::unique_ptr input_file_ptr(Util::get_resource(filename)); std::istream& input_file(*input_file_ptr); if (!input_file) { @@ -681,7 +681,7 @@ Model::load_obj(const std::string &filename) { Log::debug("Loading model from obj file '%s'\n", filename.c_str()); - const std::auto_ptr input_file_ptr(Util::get_resource(filename)); + const std::unique_ptr input_file_ptr(Util::get_resource(filename)); std::istream& inputFile(*input_file_ptr); if (!inputFile) { diff --git a/src/scene-jellyfish.cpp b/src/scene-jellyfish.cpp index bc18ee34..8750e17f 100644 --- a/src/scene-jellyfish.cpp +++ b/src/scene-jellyfish.cpp @@ -272,7 +272,7 @@ JellyfishPrivate::load_obj(const std::string &filename) { Log::debug("Loading model from file '%s'\n", filename.c_str()); - const std::auto_ptr input_file_ptr(Util::get_resource(filename)); + const std::unique_ptr input_file_ptr(Util::get_resource(filename)); std::istream& inputFile(*input_file_ptr); if (!inputFile) { From e67322bb1032956084d5be30d750b99f7c00b597 Mon Sep 17 00:00:00 2001 From: Alexandre Courbot Date: Thu, 8 Sep 2016 15:25:14 +0900 Subject: [PATCH 3/3] Fix literal suffit error with C++11 With a recent g++, compilation of src/native-state-x11.cpp will fail with the following error: ../src/native-state-x11.cpp:63:33: error: invalid suffix on literal; C++11 requires a space between literal and string macro [-Werror=literal-suffix] Add the missing space to make it go through. --- src/native-state-x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native-state-x11.cpp b/src/native-state-x11.cpp index 3b66b773..3c1703b7 100644 --- a/src/native-state-x11.cpp +++ b/src/native-state-x11.cpp @@ -60,7 +60,7 @@ NativeStateX11::display() bool NativeStateX11::create_window(WindowProperties const& properties) { - static const char *win_name("glmark2 "GLMARK_VERSION); + static const char *win_name("glmark2 " GLMARK_VERSION); if (!xdpy_) { Log::error("Error: X11 Display has not been initialized!\n");