rttr icon indicating copy to clipboard operation
rttr copied to clipboard

RTTR_REGISTRATION is broken for well separated code

Open thedmd opened this issue 4 years ago • 2 comments

I have two separate files in static library (any kind of project will do). Let's call the files a.cpp with class A and b.cpp with class B. Each has one occurrence of RTTR_REGISTRATION. Code in main.cpp does not depend on B directly in any way except rttr::type<B>::get() call. Since there are no hard dependencies, linker is throwing b.obj away from linking. All static objects from b.cpp file are gone and RTTR_REGISTRATION is never called.

For a moment I assumed rttr dealt with this problem in a way I'm now aware of yet. As it turns out this is yet to be solved.

Because of this linker behavior engines tends to have one huge file referencing known types or dummy function from files containing them. It does not even have to be called as long as linker sees reference.

Do you by any chance have solution to this problem?

thedmd avatar Jan 02 '20 00:01 thedmd

As it turns out #208 speak of same issue.

thedmd avatar Jan 02 '20 20:01 thedmd

I just wanted to say that this is an issue in our project, and we are doing some variant of this to prevent things that we need from being linker'd away:

dummy function from files containing them. It does not even have to be called as long as linker sees reference.

emxaz avatar Mar 03 '20 01:03 emxaz