|
Simon Coulter wrote: > > I'd always understood RPG didn't widen and I fully expected the > original example to fail due to the RPG prototype specifying a 2-byte > integer but I tried it in debug to confirm and the C function received > a 4-byte integer if I passed either a literal, a 5I0, or a 10I0 so I > presumed RPG was widening it. > > Hmm, what would happen if the C function expected a short and the value > was passed in a register? I presume I don't have to worry about this > and it will be "taken care of" by the run time. > Yes, that's correct. This is all handled a few levels below the RPG compiler, so I don't know exactly how "it" "knows" about the register, but I think it works for the same reason the following works: D longInt s 20i 0 D int s 10i 0 D shortInt s 5i 0 "Pass" the shortInt value to int via longInt longInt = shortInt int = longInt "Pass" the int value to shortInt via longInt longInt = int shortInt = int The transfer mechanism (the register or my "longInt") is at least as long as the other operands in the transaction, and in both the register case and my example below, the system knows everything it needs to know to get it right, assuming you have told the truth to the compilers.
As an Amazon Associate we earn from qualifying purchases.
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.