Re: Weak globals
Mark Waterbury <[email protected]> Tue, 2 Apr 2019 14:29:59 +0000 (UTC)
| Newsgroups | gmane.comp.lang.as400.c |
|---|---|
| Message-ID | <[email protected]> |
Joe:
See the ILE Concepts manual, around page 76, for a detailed explanation of "weak exports."
What are you hoping to achieve by using this feature?
(So, "ILE" really does mean "It's a Linkage Editor!") ;-)
Hope that helps,
Mark S. Waterbury
On Tuesday, April 2, 2019, 10:12:42 AM EDT, Joe Pluta <[email protected]> wrote:
Nope - still getting CPD5D03.
On 4/2/2019 9:08 AM, Joe Pluta wrote:
> Thanks Jon, that's the way I'll go if I can't figure anything else
> out. As you probably guess, I don't like DUPPROC, especially since as
> I read the documentation, weak should work.
>
> The EXPORT(*ALL) is simply for testing, but I'm not sure how the
> binder source would help. I'm not very versed in binder source, but
> as far as I can tell all binder source does is order the exported
> modules. How would it help when resolving duplicate symbols?
>
> Oh wait. Maybe that's the problem! Maybe it's trying to export both
> the weak and the strong. Ah, let me try that. If I add binder source
> to only export main maybe that will work.
>
>
> On 4/2/2019 8:53 AM, Jon Paris wrote:
>> Joe - I think dup proc is the only way to go. As to your comment "and
>> even then the order isn't _guaranteed_" that should be dealt with by
>> binder language/source instead of doing Export *All. That guarantees
>> the slot sequence.
>>
>>
>> Jon Paris
>>
>> www.partner400.com
>> www.SystemiDeveloper.com
>>
>>> On Apr 2, 2019, at 8:43 AM, Joe Pluta <[email protected]>
>>> wrote:
>>>
>>> Has anybody successfully used the weak #pragma for a function? I'm
>>> trying to create a service program with three modules: one that
>>> references a function, one with that function defined weakly, and
>>> one with the function defined strongly. In that scenario, I should
>>> be able to combine the following:
>>>
>>> Reference, weak: calls weak
>>> Reference, strong: calls strong
>>> Reference, weak, strong: calls strong
>>> Reference only: won't compile
>>>
>>> The best example code I found was in the AIX reference:
>>>
>>> https://www.ibm.com/support/knowledgecenter/SSGH3R_13.1.0/com.ibm.xlcpp131.aix.doc/compiler_ref/prag_weak.html
>>>
>>>
>>> From what I can tell, that same syntax should work in the ILE
>>> compiler, so I created the following:
>>>
>>> |// TFOO1.CPP #include <stdio.h> void foo(); int main() { foo(); }
>>> // TFOO2.CPP #include <stdio.h> #pragma weak foo__Fv void foo() {
>>> printf("Foo called from compilation unit 2\n"); } // TFOO3.CPP
>>> #include <stdio.h> void foo() { printf("Foo called from compilation
>>> unit 3\n"); } |
>>>
>>>
>>> CRTSRVPGM TFOO MODULES(TFOO1 TFOO2 TFOO3) EXPORT(*ALL) fails with
>>> CPD5D03, Definition supplied multiple times for symbol 'foo__Fv'.
>>>
>>> I can get around it with OPTION(*DUPPROC) but then I have to be very
>>> careful of the order of my modules in the MODULES keyword of
>>> CRTSRVPGM (and even then the order isn't _guaranteed_). That also
>>> would hide any cases of unintentional procedure duplication, so I'd
>>> really like to get #pragma weak working.
>>>
>>>
>>> --
>>> This is the Bare Metal Programming IBM i (AS/400 and iSeries)
>>> (C400-L) mailing list
>>> To post a message email: [email protected]
>>> To subscribe, unsubscribe, or change list options,
>>> visit: https://lists.midrange.com/mailman/listinfo/c400-l
>>> or email: [email protected]
>>> Before posting, please take a moment to review the archives
>>> at https://archive.midrange.com/c400-l.
>>>
>>> Help support midrange.com by shopping at amazon.com with our affiliate
>>> link: https://amazon.midrange.com
>
>
--
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/c400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/c400-l.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
--
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/c400-l
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/c400-l.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com