This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

The "weak attribute" usage problem

Hi,

I'm trying to use the weak attribute for the some public API definition to replace once the real APIs were NOT linked.

The step I did is like below:

1. Put kinds of  components APIs /w weak attribute function definition in one "c" file, and build it out as a library. Name it "libweak" since all functions in it is weak definition.

    And these APIs by components named "libweak.A", "libweak.B", "libweak.C" etc.

2. For these components APIs, there are strong implementation in other libraries, named "libstrong.A", "libstrong.B", "libstrong.C"

3. Now, in the final image linking once libstrong.B was removed, the final image may link libweak.B,  libweak.A,  libstrong.C.

   while the expectation linking is libweak.B, libstrong.A, libstrong.C

* I don't know following info. will help:

  The APIs of B were referenced by the c file in the project which produces the final image.

The Weak references and definitions has already referenced but didn't find the answer to this problem.

My Keil version is 5.17

Any idea on it ?

Thanks in advance

BR

hengxing

Parents
  • Hello Andreas,

    Because the files layout in my project is a little complicated and I don't know which part information may relate to the issue, 

    this results the issue can't produce. Anyway, I worked around the case after a few testing work.

    The problem case in my side is :

    1. Put all modules weak APIs(module A, B, C in previous mentioned) in a same "C" file, and produce a library libweak

    2. For these components APIs, there are strong implementation in other libraries, named "libstrong.A", "libstrong.B", "libstrong.C"

    3. Now, in the final image linking once libstrong.B was removed, the final image may link libweak.B,  libweak.A,  libstrong.C.

    My solution is :

    In the step 1, pull different modules weak APIs in separated "C" file, and still produced a library libweak. After that, following steps

    are same as before. This time, the final image like as expected:  libweak.B, libstrong.A, libstrong.C

    I'm still not sure the introduced steps are full to reproduce since my timing issue for isolating, but after this APIs reallocation, it solved my problem.

    Thanks

    Hengxing

Reply
  • Hello Andreas,

    Because the files layout in my project is a little complicated and I don't know which part information may relate to the issue, 

    this results the issue can't produce. Anyway, I worked around the case after a few testing work.

    The problem case in my side is :

    1. Put all modules weak APIs(module A, B, C in previous mentioned) in a same "C" file, and produce a library libweak

    2. For these components APIs, there are strong implementation in other libraries, named "libstrong.A", "libstrong.B", "libstrong.C"

    3. Now, in the final image linking once libstrong.B was removed, the final image may link libweak.B,  libweak.A,  libstrong.C.

    My solution is :

    In the step 1, pull different modules weak APIs in separated "C" file, and still produced a library libweak. After that, following steps

    are same as before. This time, the final image like as expected:  libweak.B, libstrong.A, libstrong.C

    I'm still not sure the introduced steps are full to reproduce since my timing issue for isolating, but after this APIs reallocation, it solved my problem.

    Thanks

    Hengxing

Children
No data