|
On 16/01/2007, at 2:25 AM, Joe Pluta wrote:
Simon, couldn't you also pass a pointer by value and explicitly set it to*NULL?
Yes, but then you'd have to define the prototype as accepting a pointer for this parameter and then you'd have to use %ADDR(feedback) if you actually wanted the feedback information. Requiring an RPG caller to mess with %ADDR on a procedure call seems incorrect to me. It is far more natural for RPG to specify scalar names rather than pointer names. Also, the documentation says use *OMIT for omissable parameters so using *NULL or a null pointer could be confusing to the next programmer.
In any case all the LE APIs expect parameters passed by reference and although we know that a pointer-by-value is the same as a scalar-by-reference this trick should be reserved for when there is no alternative.
Note also that some LE APIs expect a pointer-by-reference (e.g., the token parameter for CEEHDLR) and I think an RPG programmer would find it confusing to sometimes pass the address of a scalar and other times pass the address of a pointer. Consistency in defining prototypes for these APIs is the key to using them successfully.
There are a few cases where an API can handle a buffer larger than the 32K or 64K maximum named scalar size supported by RPG and for these %ADDR is the only option but in many/most cases that is the exception and I prefer to define a CONST scalar in prototypes even if the C version defines a pointer-by-value. Makes it much easier to use from RPG.
Regards, Simon Coulter. -------------------------------------------------------------------- FlyByNight Software OS/400, i5/OS 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 mailing list archive is Copyright 1997-2025 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.