Hello Phil,

You wrote:
>Is it possible to call from a C pgm an ILE/RPG subprocedure which 
>returns a 20 position character?  When it returns I get a pointer error.  

Yes, it is possible, but not the way you are doing it.

>I tried returning the address with %addr(filename), which didn't end in 
>error but the value wasn't correct.

Probably because the storage referenced by the pointer is automatic 
storage and has gone after the procedure returns.

> char * getHist(char[], const char[]);

indicates a pointer is being returned, but

>D getHist         pi            20  

indicates a 20-byte field is being returned. Pointers and fields are not 
compatible (except in the rather restrictive sense that C uses pointers 
and strings).

You have two choices:

        1) Change the C prototype to accept a structure containing a 
char[20] field
        2) Define filename as STATIC in the RPG procedure and return the 
address of it.

My preference is for option 1.

Simon Coulter.
   FlyByNight Software         AS/400 Technical Specialists       
   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\   
   Fax:   +61 3 9419 0175   mailto: shc@xxxxxxxxxxxxxxxxx   \ /   
                 ASCII Ribbon campaign against HTML E-Mail  / \   

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