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




On 13/01/2006, at 11:33 AM, Barbara Morris wrote:

Simon Coulter wrote:

Problem 2 is that C expects an int (4 bytes) but the prototype is
passing a 2-byte integer. RPG will widen the value because that's what
C expects but you shouldn't rely on this behaviour.


Actually, RPG doesn't widen the value.  Sometimes the parameter can get
passed in a register, and that makes it appear as though RPG widened the
value, but if the system doesn't have a register available, the
parameter gets passed "on the stack" (I don't know the mechanism). When
that happens, the called function doesn't get the value that the caller
passed.

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.

Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists

   http://www.flybynight.com.au/
   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175                                   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.