|
Scott Klement wrote:
> ...
> But, IMHO, it's a poor practice to tell the compiler that the data is
> alphanumeric in one place and numeric in another. Instead, either return
> a 4-byte integer in RPG, like this:
>
> D MYFUNCT2 PR 10U 0
> D arg 15A
>
> Or, alternately, make the C program receive a 4-byte character by value:
>
> typedef struct structTest {
> char val[4];
> } RetVal;
>
In this case, it's not just poor practice. It won't work at all if you
prototype one to return an integer and the other to return a string.
The system handles integers ("scalar" types) and strings ("aggregate"
types) differently, so even though they're both 4 bytes, they aren't
returned the same way. Same for passing by value.
If the C version wants to receive the result as an int, the struct would
be more useful like this:
typedef struct structTest {
unsigned int val;
} RetVal;
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.