Using CoSimIO in different TU / from other (linked) libraries
philbucher opened this issue · 1 comments
philbucher commented
This concerns the following line:
CoSimIO/co_sim_io/impl/co_sim_io_impl.hpp
Line 33 in b12bd32
I played around and here is my findings:
static
is internal linkage, i.e. we can include it in different TU (see also https://docs.microsoft.com/en-us/cpp/cpp/program-and-linkage-cpp?view=msvc-160)- when using
static
and including it from different libraries (e.g. Core and CoSimApp to use Kratos terms) thens_co_sim_connections
is different in the two, this is the current situation and does not work! - without
static
it works, but then I cannot include CoSimIO multiple times in different TU within the same exe/lib - For this to work too I need to use
extern
in the following way:=> now I can include CoSimIO (in one TU) ONCE regularly, the other times with#ifdef CO_SIM_IO_EXTERN extern std::unordered_map<std::string, std::unique_ptr<Connection>> s_co_sim_connections; #else std::unordered_map<std::string, std::unique_ptr<Connection>> s_co_sim_connections; #endif
CO_SIM_IO_EXTERN
like this:#define CO_SIM_IO_EXTERN #include "co_sim_io.hpp"
I didn't yet check with more complex dependencies
philbucher commented
properly fixed in #189