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



Buck Calabro wrote:
>
> >Buck, when a function wants a pointer by value,
> >you can also pass "something" by reference
> >(or CONST, aka read-only-reference), since
> >passing something by reference amounts to passing a
> >pointer-to-something by value.
>
> Thanks Barbara!  I knew that, but I get mixed up when looking at the C
> documentation because I'm not entirely sure how to tell if the parameter is
> passed by value or by reference.  Beyond that, it mixes up newbies when they
> are looking at documentation calling for a pointer and the parameter list
> has characters.  Yes, I know that "it's the way it works" but I'd rather
> have the new folks (at least where I work) read a spec and write to it so
> that their debugging is easier.

Buck, I don't disagree in the case where the documentation says it wants
a pointer to anything that it's probably best to code it in RPG as a
pointer by value.

C always passes parameters by value.
    int    - integer
    int *  - pointer to integer
    int ** - pointer to pointer to integer
But since RPG passes by value and by reference, "pointer to integer"
should be read as "integer passed by reference".

Say the documentation says it requires a pointer to an integer.  In that
case, it would be a disservice to callers using the RPG prototype to
simply code a pointer by value.  Coding an integer by reference makes
the prototype much more useful (the compiler can do the type checking,
and the programmer can code the call naturally).  The prototype's
documentation can explain the details for newbies and oldbies.

 * int someFn (int *x, void *y, char *z, const char *w);
D someFn       pr
 * pointer to integer (integer passed by reference)
D   x                    10i 0
 * pointer to anything
D   y                      *    value
 * pointer to null-terminated string
D   z                      *    value options(*string)
 * pointer to 10 bytes, blank-filled
D   z                    10a    const




As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.