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



James,

options(*string) causes RPG to make a copy of your variable and add a x'00' to the end, then pass that temporary copy. You cannot use options(*string) for an output (or in/out) parameter.

Instead, consider passing buffy as an alphanumeric field (NOT a pointer). If it needs to be null-terminated on the RPG side, then use the %str() BIF to null-terminate it before you pass it.

Also, you forgot the RETURN VALUE on your RPG prototype. Your C prototype returns an int -- but the RPG side shows no return value. Change it to have 10i 0 as a return value, otherwise those 4 bytes that are returned could possibly be overwriting memory used for something else -- and that might be hard to catch in testing, but could result in the dreaded "unexpected results" in production.

James Lampert wrote:
I have a C procedure called by an RPG program:

In the RPG program, it is prototyped thusly:

D FOO PR EXTPROC('foo')
D * VALUE OPTIONS(*STRING)
D * VALUE OPTIONS(*STRING)
D 10I 0 VALUE
D * VALUE OPTIONS(*STRING)
D * VALUE OPTIONS(*STRING)

and called thusly:

C CALLP FOO(X,Y,I,K,BUFFY)

and the C procedure is:

int foo(char *opcode, char *filename, int len, char *key, char *buffy) {
/* here we read a record from a file, putting the record into buffy */

A printf() statement in the C procedure tells me that the record definitely gets read from the file, and it's definitely the right record. Yet when control returns to the calling program, the record is gone, and what was originally in BUFFY is back.

Obviously, I'm doing *something* wrong here.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.