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



 >> Both explanations do help me with a segue question I was going to ask,
which is what is the proper way to pass data structures back and forth
between C and RPG.

Whilst there is very little documentation to show C programmers how to write
to interface to RPG there is a lot of information out there showing how to
use C functions from RPG.  You might want to check a few of those out.

One source is the RPG Redbook "Who Knew You Could Do That With RPG IV"
(http://publib-b.boulder.ibm.com/Redbooks.nsf/RedbookAbstracts/sg245402.html
) which has examples of everything from accessing IFS files, to dynamic
memory, to sockets, to ....

Scott Klement modestly failed to mention his own site
(http://www.scottklement.com) which has excellent tutorials on sockets and
IFS usage.  Since both of these use Structs in the C sense you can readily
get a feel for how to structure things.

Probably the definitive work on interfacing C and RPG is by Barbara Morris
(from the RPG compiler team) and you can find it here
(http://www.opensource400.org/callc.html)

I think it is also worthwhile pointing out that if your intent is for the C
function to be readily usable by the average RPG programmer, that returning
a pointer is probably not a good idea anyway.  C programmers have no real
choice but to use pointers for strings as others have said.  RPG programmers
do not expect to _have_ to handle pointers.  They accept it when they know
they are dealing with a C library function, but get antsy when forced to
play with %str when they don't have to.  If your function will be used by
both C and RPG programs, you are going to have to compromise and either
annoy the C users (as Simon mentioned) or the RPG ones.  If the function
will only be used by RPG, I'd make it a bit more RPG friendly.



Jon Paris
Partner400

www.Partner400.com
www.RPGWorld.com


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