How to store enumerate types/store type info across modules in C++

  amazon-ecs, c++, rtti

I’m working on a game engine incorporating ECS. I have a pretty straightforward setup – my engine is in a DLL and my game module is the .EXE which attaches the DLL. I have created an ECS using dense memory block allocations and I’m focusing quite a lot on performance. For the very basis of the ECS i use a type info structure to enumerate different entity component types. I basically use function pointers to templated functions as a way to enumerate different types. It is defined as follows:

struct ComponentTypeInfo
     typedef (*_InternalId)();
     _InternalId TypeId;
     size_t TypeSize;
     static void TypeId() {}
template<typename TComponent>
struct GetComponentTypeInfo : public ComponentTypeInfo
     GetComponentTypeInfo() : ComponentTypeInfo(TypeId<TComponent>, sizeof(TComponent))

The problem: In practice this works fine, however it breaks when types are compared across modules due to function instances being seperate. This causes the the function pointers to be different, and therefore the Ids to be different. I have tried a bunch of things but they all come to the same issue regarding module boundries.

What I have thought of so far:

  1. Making sure only one module uses type info – Practically impossible since the engine has own component types predefined to use in systems.
  2. Using a counter/increment-style id – Still encounters the same problem – any way of attaching ids to types encounters the problem that templated functionality is always instantiated in its own module, thus the ids would never match.
  3. Using inheritence – since the ECS uses densely packed memory blocks, type erasure happens very early on and the logic working with memory blocks and stacks doesnt have the compile-time information of the types stored. Just the type ids.
  4. I want to stay away from STL unless I absolutely need to use it. However I might end up using a wrapper around it if nothing else works. Libraries (boost, etc) are not a consideration.

Is there any there any senseble way to enumerate types across modules? Is RTTI only made to be available to STL?

Source: Windows Questions C++