× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.