I am using IAR EWARM 8.10.1 which uses the ILINK linker.
I have a common header that two compilation units use. It includes prototypes of functions with external linkage and constitutes an API. Depending on how the build is configured I would like Module A or B to be linked with rest of my application.
[ Common_Header.h ]
| |
| +----- [Module_A.c] ---> [Module_A.o]
|
+--------------- [Module_B.c] ---> [Module_B.o]
Somehow I would like to pass an argument to ilinkarm.exe to include Module_A.o.
Other IAR toolchains I have used in the past used the XLINK linker. XLINK had a -A option, and I suppose that is similar to what I need.
What I am essentially wanting is for the function definitions in Module_B to be treated as if they were __weak when Module_A is active and vice versa.
I would like to avoid putting #pragma weak in my code if possible. I need to be able to compile this code with a few different tool chains. So I would need to wrap any such pramgas with something like #ifdef __ICCARM__. Furthermore, I'd need to define some extra preprocessor symbol to conditionally make one module weak when the other is active. This is all complexity I'd prefer to keep out of the code.
Furthermore, I do not want to exclude module_B from the build when module_A is active. I want both modules to always compile. If someone makes changes to the interface and in module_A, but fails to update module_B, I would like them to get a compiler error. This will keep module_B from getting in some orphaned and broken state as the interface evolves and our attentions is focused on module_A.
I have reviewed EWARM_DevelopmentGuide.ENU.pdf and I can't find a command line option that seems to do what I want. I would like to know if such an option exists and I have missed it, or if there is another way to accomplish what I am after.
__weakkeyword). - user694733