|
On 10/6/2016 4:58 PM, Peter Dow wrote:
I was under the impression that parameters are passed by reference, i.e.It is indeed.
a pointer is passed. Is that not the case?
You're overlooking what the RPG compiler will do with that address when
it gets it.
DCL &RC *CHAR 2
DCL &CALLER *CHAR 10
DCL &PARMS *CHAR 111
CALL PGM(OB0050AN) PARM(&RC &CALLER &PARMS)
Let's pretend we're IBM i for a moment. There are 3 variables; each
needs to be stored in memory.
Address Contents
1 RC
3 CALLER
13 PARMS
When the RPGLE program is called, the three addresses are passed to it:
CALL PGM(OB0050AN) PARM(1 3 13)
Then the RPG program begins executing:
d OB0050AN pi
d @RETURNCODE 2a
d @CALLER 10a
d ptrPARMS *
At this point, the RPG compiler looks at the memory addresses in the
order they were passed. It sees that it ought to look at memory
location 1, and put 2 bytes of character data into @RETURNCODE. It sees
that it ought to look at memory location 3, and put 10 bytes of
character data into @CALLER. Finally, it sees that it ought to look at
memory location 13 and put a pointer in PTRPARMS.
But pointers on IBM i have a special flag indicating that they are a
legal pointer. We can't simply forge one out of random binary data - in
order to assign a pointer, it needs to be an honest to goodness pointer
that's been passed along at address 13. And there's no pointer there;
only character data. No special pointer flag, so the assignment to the
pointer data type will fall over.
tl;dr The RPG compiler is trying to map non-pointer data to a pointer
data type and telling you that doing so is an illegal operation.
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.