From 043c1772ae20eb7372243631d3fbaf8e8dd5257d Mon Sep 17 00:00:00 2001 From: Thomas Peters Date: Thu, 18 May 2023 21:03:58 -0400 Subject: [PATCH] non-boost build fixes (#756) * Time.cpp: include Time.cpp uses `std::round` from . When SLANG_USE_BOOST is on, cmath is pulled in somehow from a transitive include. When SLANG_USE_BOOST is off, at least on some systems, this include is not pulled in. Include explicitly in Time.cpp to ensure `std::round` is available, including for certain non-boost-using builds. * pyslang.h: guard type_casters for flat_hash_map based on SLANG_USE_BOOST include/slang/util/Hash.h defines the alias templates `flat_hash_map` and `flat_hash_set` based on the macro SLANG_USE_BOOST. If the macro is defined, these aliases refer to boost class templates. If the macro is not defined, they reference standard class templates. Pybind11 v2.10.4 defines type_casters for `std::unordered_map` and `std::unordered_set` in include/pybind11/stl.h on lines 302-304 and 294-296, respectively. As pyslang.h includes , avoid multiple definitions of these type casters by guarding their definitions in pyslang.h based on the SLANG_USE_BOOST macro. --- bindings/python/pyslang.h | 2 ++ source/numeric/Time.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/bindings/python/pyslang.h b/bindings/python/pyslang.h index caea47766..bf3e31f32 100644 --- a/bindings/python/pyslang.h +++ b/bindings/python/pyslang.h @@ -167,6 +167,7 @@ struct type_caster> { std::span value; }; +#ifdef SLANG_USE_BOOST // Convert between flat_hash_map and python dict. template struct type_caster> @@ -176,6 +177,7 @@ struct type_caster> template struct type_caster> : set_caster, Key> {}; +#endif template class type_caster> { diff --git a/source/numeric/Time.cpp b/source/numeric/Time.cpp index 0427eac7e..e6f3c3d87 100644 --- a/source/numeric/Time.cpp +++ b/source/numeric/Time.cpp @@ -7,6 +7,7 @@ //------------------------------------------------------------------------------ #include "slang/numeric/Time.h" +#include #include #include