Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access violation on type_register.cpp::549 get_base_types() #353

Open
btgoodwin opened this issue Mar 14, 2023 · 0 comments
Open

Access violation on type_register.cpp::549 get_base_types() #353

btgoodwin opened this issue Mar 14, 2023 · 0 comments

Comments

@btgoodwin
Copy link

I'm using the RTTR commit 7edbd58 as my reference on Windows, using MSVC's cl as my compiler (2022).

I have a pair of libraries, let's call them library A and B. A depends on B. Both A and B have headers with publicly visible C++ structs like this:

#pragma once

#include <rttr/type>

namespace library_b {
struct SomeStructInB {
// usual declarations
RTTR_ENABLE();
};
};

Then within various object files, I include rttr/registration and have RTTR_REGISTRATION { ... };. In other words libraryB/somestructinb.cpp has a single RTTR_REGISTRATION ..., another file libraryB/anotherstructinb.cpp has another RTTR_REGISTRATION for its structs/classes, and so forth. The same applies to library A. For the above example, its cpp file would look like this:

#include "somestructinb.h"

namespace library_b {
RTTR_REGISTRATION {
rttr::registration::Class_<SomeStructInB>("some-struct-in-b")
    .constructor<>(); // and so forth.
};
};

In Library A, I have implemented a serialization routine for RTTR types so that I can deal with serializing and deserializing both library A's and library B's types.

At runtime, I get an access violation on the aforementioned get_base_types() call, and I'm not sure why. The stack trace's last line of my code is in the Library A's RTTR_REGISTRATION. The documentation seems to be suggesting this design is possible, that a given object file may have exactly one RTTR_REGISTRATION call, which is what I've implemented. Quoting the docs found here:

It is not possible to place the macro multiple times in one cpp file.

Therefore, it is possible to place the macro multiple times as long as it's only once per cpp file.

In a completely different project, I have rttr working fine, but in the whole of all of its dependencies, that project has exactly one instance of RTTR_REGISTRATION throughout the entire codebase.

I'm not sure where to look for why this access violation is occurring. Can someone please point me in the right direction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant