From c0246ce2af4e287b765ded8a85a015f82deb9f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Masiukiewicz?= Date: Thu, 27 Oct 2022 23:29:50 +0200 Subject: [PATCH] Syntax '*ptr = Structure.init' requires opAssign operator, get rid of this requirement by using malloc. This is useful when component is defined in another shared library and we use '-fvisibility=hidden', in that case opAssign is hidden and we will get 'undefined symbol' --- source/bubel/ecs/manager.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/bubel/ecs/manager.d b/source/bubel/ecs/manager.d index fb43f67..7861649 100644 --- a/source/bubel/ecs/manager.d +++ b/source/bubel/ecs/manager.d @@ -1307,7 +1307,8 @@ export struct EntityManager info.size = Comp.sizeof; info.alignment = Comp.alignof; //8; info.init_data = Mallocator.makeArray!ubyte(Comp.sizeof); - *cast(Comp*) info.init_data.ptr = Comp.init; // = Comp(); + __gshared Comp init_memory; + memcpy(info.init_data.ptr, &init_memory, Comp.sizeof); ushort comp_id = components_map.get(cast(char[]) ComponentName, ushort.max); if (comp_id < components.length)