Having pointer to instance of class in another class and other way around

92 views Asked by At

I have a C++ static library A and a C++ shared library B(Android HAL). I want to have a pointer to an instance of class A inside class B and a pointer to an instance of class B inside class A.

The purpose of this is to have multi-directional communication between the two instances. Registration of callbacks is not an option because of multiple callbacks with different signatures. class A:

cc_library_static {
    name: "static_lib_A",
    relative_install_path: "hw",
    vendor: true,

    shared_libs: [
         "shared_lib_B"
    ],
    
    srcs: [
         "staticLibA.cpp"
    ]
}

class B:

cc_library_shared {
    name: "shared_lib_B",
    vendor: true,

    whole_static_libs: [
         "static_lib_A
    ],
    
    srcs: [
         "sharedLibB.cpp"
    ]
}

Both classes cannot be bundled in one library because one is compiled using RTTI and the other is not.

This causes a cyclic dependency error. Is there a way to resolve this?

Thanks.

0

There are 0 answers