Return to the RPG Tips
Rules for converting C prototypes to RPG prototypes are as follows:
Even though int * is a pointer, it can be thought of as an int passed by reference, so it's better to prototype it in RPG as an int passed by reference. C | RPG ----------------|------------------------------------------- int, long | 10i 0 value unsigned int | 10u 0 value double | 8f value int * | 10i 0 unsigned * | 10u 0 double * | 8F char * | * value options(*string) void * | * value | OR LIKE(someStructure) XXX | value LIKE(XXX) XXX * | LIKE(XXX) ... (ellipsis)| figure out what the ... stands for | and make one or more prototypes to | match the various combinations, possibly | with OPTIONS(*NOPASS) on some parms Where XXX is some struct/union, defined in RPG as a data structure. This part is for those advanced folks who know C and are creating RPG prototypes for homegrown C functions (i.e. not part of the C runtime): Also, watch out for C's widening rules. Even though short = 5I 0, when it comes to passing parameters by value, short=10i 0 and char=10u 0. These differences don't always cause a problem since the use of registers to pass parameters can cause these differences to be hidden. Luckily, the C runtime rarely if ever has short or even char parameters passed by value. Unfortunately, C doesn't ALWAYS widen - it depends on the absense of a #pragma nowiden. Barbara Morris
[report a broken link by clicking here]