From 08787c5610147727de4c1e362b30fe11429c6a41 Mon Sep 17 00:00:00 2001 From: slayoo Date: Thu, 30 Jul 2015 14:26:51 +0200 Subject: [PATCH] fixing multiple translation unit proble. Closes #309. --- libmpdata++/formulae/arakawa_c.hpp | 4 +++- libmpdata++/output/detail/xdmf_writer.hpp | 4 ++-- libmpdata++/solvers/detail/monitor.hpp | 4 ++-- tests/unit/CMakeLists.txt | 1 + tests/unit/mltpl_transl_unit/CMakeLists.txt | 4 ++++ .../test_mltpl_transl_unit.cpp | 1 + .../test_mltpl_transl_unit.hpp | 17 +++++++++++++++++ tests/unit/mltpl_transl_unit/u1.cpp | 3 +++ tests/unit/mltpl_transl_unit/u2.cpp | 3 +++ 9 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 tests/unit/mltpl_transl_unit/CMakeLists.txt create mode 100644 tests/unit/mltpl_transl_unit/test_mltpl_transl_unit.cpp create mode 100644 tests/unit/mltpl_transl_unit/test_mltpl_transl_unit.hpp create mode 100644 tests/unit/mltpl_transl_unit/u1.cpp create mode 100644 tests/unit/mltpl_transl_unit/u2.cpp diff --git a/libmpdata++/formulae/arakawa_c.hpp b/libmpdata++/formulae/arakawa_c.hpp index ef3ba1c8..65ae6b26 100644 --- a/libmpdata++/formulae/arakawa_c.hpp +++ b/libmpdata++/formulae/arakawa_c.hpp @@ -12,7 +12,9 @@ namespace libmpdataxx { namespace arakawa_c { - struct hlf_t {} h; + namespace { + struct hlf_t {} h; + } inline rng_t operator+( const rng_t &i, const hlf_t & diff --git a/libmpdata++/output/detail/xdmf_writer.hpp b/libmpdata++/output/detail/xdmf_writer.hpp index f6ff9a6c..0fa6711a 100644 --- a/libmpdata++/output/detail/xdmf_writer.hpp +++ b/libmpdata++/output/detail/xdmf_writer.hpp @@ -13,7 +13,7 @@ namespace libmpdataxx { namespace output { - namespace detail + namespace detail { namespace { template class xdmf_writer @@ -201,6 +201,6 @@ namespace libmpdataxx const std::string xdmf_writer::name = "Grid"; template const std::string xdmf_writer::grid_type = "Uniform"; - } + }} } } diff --git a/libmpdata++/solvers/detail/monitor.hpp b/libmpdata++/solvers/detail/monitor.hpp index cc881bc6..18d1f34a 100644 --- a/libmpdata++/solvers/detail/monitor.hpp +++ b/libmpdata++/solvers/detail/monitor.hpp @@ -14,7 +14,7 @@ namespace libmpdataxx { namespace solvers { - namespace detail + namespace detail { namespace { void monitor(float frac) { @@ -38,7 +38,7 @@ namespace libmpdataxx #elif defined(HAVE_PTHREAD_SETNAME_NP) && defined(HAVE_PTHREAD_GETNAME_NP) pthread_setname_np(name); #endif - } + }} }; }; }; diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 0a2015d5..0b600f80 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -41,3 +41,4 @@ add_subdirectory(concurrent_1d) add_subdirectory(hint_scale) add_subdirectory(hdf5_catch) add_subdirectory(git_revision) +add_subdirectory(mltpl_transl_unit) diff --git a/tests/unit/mltpl_transl_unit/CMakeLists.txt b/tests/unit/mltpl_transl_unit/CMakeLists.txt new file mode 100644 index 00000000..cc32a6eb --- /dev/null +++ b/tests/unit/mltpl_transl_unit/CMakeLists.txt @@ -0,0 +1,4 @@ +# this is a compile-only test, nothing us run during "make test" +add_executable(mltpl_transl_unit test_mltpl_transl_unit.cpp u1.cpp u2.cpp) +target_link_libraries(mltpl_transl_unit ${libmpdataxx_LIBRARIES}) +target_include_directories(mltpl_transl_unit PUBLIC ${libmpdataxx_INCLUDE_DIRS}) diff --git a/tests/unit/mltpl_transl_unit/test_mltpl_transl_unit.cpp b/tests/unit/mltpl_transl_unit/test_mltpl_transl_unit.cpp new file mode 100644 index 00000000..237c8ce1 --- /dev/null +++ b/tests/unit/mltpl_transl_unit/test_mltpl_transl_unit.cpp @@ -0,0 +1 @@ +int main() {} diff --git a/tests/unit/mltpl_transl_unit/test_mltpl_transl_unit.hpp b/tests/unit/mltpl_transl_unit/test_mltpl_transl_unit.hpp new file mode 100644 index 00000000..6a96ea6f --- /dev/null +++ b/tests/unit/mltpl_transl_unit/test_mltpl_transl_unit.hpp @@ -0,0 +1,17 @@ +#pragma once + +#include +#include + +struct ct_params_t : libmpdataxx::ct_params_default_t +{ + enum { n_dims = 3 }; + enum { n_eqns = 3 }; + using real_t = double; +}; + +using slv_out_t = libmpdataxx::output::hdf5_xdmf< + libmpdataxx::solvers::mpdata< + ct_params_t + > +>; diff --git a/tests/unit/mltpl_transl_unit/u1.cpp b/tests/unit/mltpl_transl_unit/u1.cpp new file mode 100644 index 00000000..6186c357 --- /dev/null +++ b/tests/unit/mltpl_transl_unit/u1.cpp @@ -0,0 +1,3 @@ +#include "test_mltpl_transl_unit.hpp" + +slv_out_t s1(slv_out_t::rt_params_t()); diff --git a/tests/unit/mltpl_transl_unit/u2.cpp b/tests/unit/mltpl_transl_unit/u2.cpp new file mode 100644 index 00000000..06421c80 --- /dev/null +++ b/tests/unit/mltpl_transl_unit/u2.cpp @@ -0,0 +1,3 @@ +#include "test_mltpl_transl_unit.hpp" + +slv_out_t s2(slv_out_t::rt_params_t());