How can two C ++ libraries share a static buffer?

Introduction

I am developing my first embedded application (on Arduino) that accepts input and controls several components of a shelf. This is a fully private nonprofit project. (Just a little fun / workout for my own benefit.)

The Arduino library is just an archived C ++ source collection with one C ++ and .h file, which represent the interface for the library. For the purposes of this question, simply consider each library as a source collection that I have acquired from someone else.

Two of the more complex components can be controlled using freely available libraries (with a good reputation) that I want to use to avoid re-creating the wheel. However, both libraries declare multiple arrays that consume too much limited data space.

When I start, my application will check the switch, which will determine which of the two components will be used until the next power cycle. I will never use both components at the same time.

What is my problem?

I would like to change the libraries to share the same space in RAM, but I found that my knowledge of C ++ is too limited.

What does existing code look like?

Library A declares buffers as follows:

class A
{
 public:
    char name[50];
    char address[100];
}

Library B declares buffers as follows:

class B
{
 public: 
    static char name[];
    static char address[];
}

B :

    char B::name[50];
    char B::address[100];

A, , . B , .

B, , . , . , .

, B: name [] B:: address [] A, B A .

, , , . B.

, , B, .

- - , , ?

+4
2

, , .

class B, ?

class B
{
 public: 
    static char* name;
    static char* address;
}

B :

char name[50];
char address[100];
char* B::name = name;
char* B::address = address;

name address class A, .

, : B?

-, . , , , .

, , , . , . , .

, , , , .

+1

, sizeof(A)>=150, sizeof(B::name) < 150 sizeof(B::address) <150. , B, , A. , 150 A, .

, . A ; char* name char* address. B. , . , kludges - , , Arduino. dlopen() libA libB, . .

0

Source: https://habr.com/ru/post/1677770/