From 56ffce62237cfe3262a11493d1860e88fdc636cf Mon Sep 17 00:00:00 2001 From: Hans Dembinski Date: Mon, 2 Jul 2018 21:21:46 +0200 Subject: [PATCH] fix of build system and some gcc warnings --- build/CMakeLists.txt | 20 ++++++++----------- build/get_python_include.py | 3 +++ build/get_python_library.py | 6 ++++++ include/boost/histogram/detail/utility.hpp | 2 +- include/boost/histogram/dynamic_histogram.hpp | 2 +- include/boost/histogram/static_histogram.hpp | 2 +- .../histogram/storage/adaptive_storage.hpp | 4 ++-- .../histogram/storage/weight_counter.hpp | 6 +----- src/python/histogram.cpp | 2 +- test/detail_test.cpp | 2 +- test/histogram_test.cpp | 2 +- 11 files changed, 26 insertions(+), 25 deletions(-) create mode 100644 build/get_python_include.py create mode 100644 build/get_python_library.py diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index d80d214d..6def8204 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -62,23 +62,19 @@ if(BUILD_PYTHON) find_package(PythonInterp REQUIRED) endif() - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig, sys; sys.stdout.write(sysconfig.get_paths()[\"include\"])" - OUTPUT_VARIABLE PYTHON_INCLUDE_DIRS) + execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/get_python_include.py + OUTPUT_VARIABLE PYTHON_INCLUDE) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sysconfig, sys; sys.stdout.write(sysconfig.get_paths()['stdlib'] + '/..')" - OUTPUT_VARIABLE PYTHON_PREFIX) + execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/get_python_library.py + OUTPUT_VARIABLE PYTHON_LIBRARY) - find_library(PYTHON_LIBRARIES - NAMES python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} - PATHS ${PYTHON_PREFIX} - NO_DEFAULT_PATH) - message(STATUS "Python lib: ${PYTHON_LIBRARIES}") + message(STATUS "Python include: ${PYTHON_INCLUDE}") + message(STATUS "Python lib: ${PYTHON_LIBRARY}") message(STATUS "Beware: Python lib MUST match what Boost.Python was compiled against") - message(STATUS "Python include: ${PYTHON_INCLUDE_DIRS}") - include_directories(${PYTHON_INCLUDE_DIRS}) + include_directories(${PYTHON_INCLUDE}) find_package(Boost 1.63 REQUIRED COMPONENTS iostreams serialization) - set(LIBRARIES ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) + set(LIBRARIES ${Boost_LIBRARIES} ${PYTHON_LIBRARY}) find_library(Boost_PYTHON NAMES boost_python boost_python${PYTHON_VERSION_MAJOR} boost_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR} diff --git a/build/get_python_include.py b/build/get_python_include.py new file mode 100644 index 00000000..d616d5cf --- /dev/null +++ b/build/get_python_include.py @@ -0,0 +1,3 @@ +from distutils import sysconfig +import sys +sys.stdout.write(sysconfig.get_python_inc()) \ No newline at end of file diff --git a/build/get_python_library.py b/build/get_python_library.py new file mode 100644 index 00000000..eee23e49 --- /dev/null +++ b/build/get_python_library.py @@ -0,0 +1,6 @@ +from distutils import sysconfig +import os.path as op +import sys +v = sysconfig.get_config_vars() +fpaths = [op.join(v[pv], v['LDLIBRARY']) for pv in ('LIBDIR', 'LIBPL')] +sys.stdout.write(list(filter(op.exists, fpaths))[0]) \ No newline at end of file diff --git a/include/boost/histogram/detail/utility.hpp b/include/boost/histogram/detail/utility.hpp index 8a0479a7..12ce89b7 100644 --- a/include/boost/histogram/detail/utility.hpp +++ b/include/boost/histogram/detail/utility.hpp @@ -105,7 +105,7 @@ indirect_int_cast(T&&t) noexcept { return static_cast(std::forward(t)); template typename std::enable_if::value), int>::type -indirect_int_cast(T&&t) noexcept { +indirect_int_cast(T&&) noexcept { // Cannot use static_assert here, because this function is created as a // side-effect of TMP. It must be valid at compile-time. BOOST_ASSERT_MSG(false, diff --git a/include/boost/histogram/dynamic_histogram.hpp b/include/boost/histogram/dynamic_histogram.hpp index c67a7971..7888f556 100644 --- a/include/boost/histogram/dynamic_histogram.hpp +++ b/include/boost/histogram/dynamic_histogram.hpp @@ -426,7 +426,7 @@ private: } } - template void xlin_get(mpl::int_<0>, std::size_t&, std::size_t &, T&&t) const noexcept {} + template void xlin_get(mpl::int_<0>, std::size_t&, std::size_t &, T&&) const noexcept {} template void xlin_get(mpl::int_, std::size_t& idx, std::size_t & stride, T&&t) const { diff --git a/include/boost/histogram/static_histogram.hpp b/include/boost/histogram/static_histogram.hpp index f2a54a4b..4d5344e8 100644 --- a/include/boost/histogram/static_histogram.hpp +++ b/include/boost/histogram/static_histogram.hpp @@ -105,7 +105,7 @@ public: } template - bool operator==(const histogram &rhs) const noexcept { + bool operator==(const histogram &) const noexcept { return false; } diff --git a/include/boost/histogram/storage/adaptive_storage.hpp b/include/boost/histogram/storage/adaptive_storage.hpp index 5a579d3c..4b804d10 100644 --- a/include/boost/histogram/storage/adaptive_storage.hpp +++ b/include/boost/histogram/storage/adaptive_storage.hpp @@ -339,7 +339,7 @@ struct radd_array_visitor : public static_visitor { for (auto i = 0ul; i < rhs.size; ++i) apply_visitor(radd_visitor(lhs_any, i, rhs[i]), lhs_any); } - void operator()(const array &rhs) const {} + void operator()(const array &) const {} }; struct rmul_visitor : public static_visitor { @@ -434,7 +434,7 @@ public: } void add(std::size_t i, const element_type &x) { - if (x.has_trivial_variance()) { + if (x.variance() == x.value()) { apply_visitor(detail::radd_visitor(buffer_, i, x.value()), buffer_); } else { diff --git a/include/boost/histogram/storage/weight_counter.hpp b/include/boost/histogram/storage/weight_counter.hpp index b9e60a37..49ac7957 100644 --- a/include/boost/histogram/storage/weight_counter.hpp +++ b/include/boost/histogram/storage/weight_counter.hpp @@ -94,8 +94,6 @@ public: const RealType &value() const noexcept { return w; } const RealType &variance() const noexcept { return w2; } - bool has_trivial_variance() const noexcept { return w == w2; } - // conversion template explicit weight_counter(const T &t) : w(static_cast(t)), w2(w) {} @@ -104,9 +102,7 @@ public: return *this; } operator RealType() const { - // if (!has_trivial_variance()) - // throw std::logic_error("cannot convert weight_counter to RealType, " - // "value and variance differ"); + // lossy conversion should be explicit return w; } diff --git a/src/python/histogram.cpp b/src/python/histogram.cpp index 57d002b6..cdff4ffa 100644 --- a/src/python/histogram.cpp +++ b/src/python/histogram.cpp @@ -76,7 +76,7 @@ public: object operator()(const Array& b) const { return make_tuple(reinterpret_cast(b.begin()), true); } - object operator()(const array& b) const { + object operator()(const array& /* unused */) const { // cannot pass non-existent memory to numpy; make new // zero-initialized uint8 array, and pass it return np::zeros(tuple(shapes), np::dtype::get_builtin()); diff --git a/test/detail_test.cpp b/test/detail_test.cpp index b3cd6aed..cfe27f45 100644 --- a/test/detail_test.cpp +++ b/test/detail_test.cpp @@ -160,7 +160,7 @@ int main() { BOOST_TEST_TRAIT_TRUE(( std::is_same )); using result3a = classify_container_t&>; - BOOST_TEST_TRAIT_TRUE(( std::is_same )); + BOOST_TEST_TRAIT_TRUE(( std::is_same )); using result4 = classify_container_t; BOOST_TEST_TRAIT_TRUE(( std::is_same )); diff --git a/test/histogram_test.cpp b/test/histogram_test.cpp index f3cf58f4..717e84cb 100644 --- a/test/histogram_test.cpp +++ b/test/histogram_test.cpp @@ -69,7 +69,7 @@ typename Histogram::element_type sum(const Histogram& h) { } template -void pass_histogram(boost::histogram::histogram &h) {} +void pass_histogram(boost::histogram::histogram &) {} template void run_tests() {