× 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 5/1/2013 6:14 AM, whatt sson wrote:
...
if i need to pass lots of data (in principle always if i want to pass more
than just a basic type) i pass a pointer. ... I don't see a real
downside in this approach ...

RPG doesn't have typed pointers.

Take this C function
myFn (int *p);

The exact RPG equivalent is

D myFn PR
D p 10i 0

Both the C and RPG prototypes say that the parameter is an integer passed by reference. The C version can also be stated as "pointer to integer passed by value". But that's not possible to code in RPG. This RPG prototype

D myFn PR
D p * value

is not equivalent to the C prototype, because that RPG prototype simply says "pointer passed by value". The "integer" part of the C prototype is lost.

If you pass the address of a float to the C function, the C ocmpiler will complain. If you pass the address of a float to the second RPG function, the RPG compiler won't care, because you haven't told it to expect a pointer to an integer.

If you decide to manage passing the correct data types yourself, you're back in the bad old days of CALL + PARM, where the compiler oculd not do any type checking.


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.