Lim Hock-Chai wrote:
Barbara, I'm a bit lost. You say my RPG prototype should be 10A, not *string.
But your example showing RPG protype with *string.

If you want your callers to pass you 10A or 2048A with trailing blanks, then the RPG prototype should say that, and be 10A. And the C typedefs should also be 10 bytes long, using your structs.

But I think it would be better if you changed your procedure so it didn't require your callers to pass 10A or 2048A with trailing blanks. Instead, require them to pass a null-terminated string. Your procedure can then get the blank-filled 10A or 2048A value quite easily from the null-terminated parameters, using %STR.

I really prefer to do typedef struct { char value[10]; } logECD_STP3_piModuleName_T;

But I don't want to have to do below in c just to call a function:
memset(&piModuleName, ' ', sizeof(piModuleName));
memcpy(&piModuleName, "MYMODULE",8);

I want to do this, hence, I changed it to use *string

Clear as mud?

Crystal clear. Basically, you have a trade-off between the convenience of coding your procedure, and the convenience of calling your procedure. Your procedure needs a 10A with trailing blanks, so you are putting a requirement on your caller to pass it exactly the way you need it.

If you only have RPG callers, there's no difference in the convenience of calling; the call is the same for 10A and for * options(*string). But for a C caller, you have seen how awkward it is to pass a 10A parameter.

As a rule of thumb, favour the convenience of your callers. You only write the procedure once, but you might call it many times. So it's worth taking a bit of extra trouble in the procedure or a bit of extra trouble choosing prototype keywords, if it makes it easier to call the procedure.

In this case, it's only a tiny bit of extra trouble.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by 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.