sublime78ska=K2GnTyEPumIAvxtiuMwx3w@public.gmane.org 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.  I tried returning
> the address with %addr(filename), which didn't end in error but the value 
>wasn't
> correct.
> 
> Here's the c pgm:
> ...
>  char * getHist(char[], const char[]);
> ...
> here's the rpg procedure:
> ...
> D getHist         pi            20
> ...

Phil, you can either have the C program expect a structure or have the
RPG procedure return a pointer.

  typedef struct char20
  {
     char c[20];
  } char20_t
  char20_t getHist(char[], const char[]);

  char20_t retval;
  filename = &retval;
  retval = getHist(isodate, "OCT");

Or you could have the RPG procedure return a pointer as long as it
returned a pointer to static storage.

  D getHist         pi              *
  ...
  D filename        s             20    static
  ...
  C                   return    %addr(filename)

By the way, you can avoid the #pragma map by specifying
EXTPROC('getHist') on your RPG procedure.  I think it was in V4R2 that
RPG started allowing that.


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