× 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.



Simon Coulter wrote:

So although C always widens the return value telling RPG that it's not
widened makes things work. Why is that so? Is it because RPG is being
warned that a C function is being called, it knows the C function will
always widen the return value, and so it adjusts which bytes of the
return value it uses according to the size and type of the variable
specified on the left-hand side of the assignment?

I don't know why this is; only that it is one of the things I have to
remember when using a C module in a service program.

My conclusion is that unless I specify either *CWIDEN or *CNOWIDEN I
cannot make C and RPG behave properly and since I have other reasons for
not using those my only option is to write a conversion routine in a
language other than C (e.g., RPG) to convert the int returned by C into
a 1-byte char for use by RPG or COBOL.

I'm lucky here in that I don't have any C consumers. All my mainline
code is RPG and I have a very few C subprocedures providing services to
them. I'm not hamstrung by the widening issue - I can freely provide
the nowiden #pragma because I don't have to worry about interoperability
with C programs.

It's not a satisfying answer, but it seems like a design decision to
enable ported C applications to be able to rely on typical C behaviour
even though this provides a quirk in cross language interoperability.
--buck

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.