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


  • Subject: Re: C Functions..
  • From: bmorris@xxxxxxxxxx
  • Date: Thu, 19 Aug 1999 09:23:11 -0400


>Date: 18 Aug 1999 16:30:06 -0500
>From: "Scott Klement" <infosys@klements.com
>...
>In general, though:
>
>         int,long                         10I 0
>         unsigned int, unsigned long      10U 0
>...
>         in C, pointers point at a specific data type, in
>         RPG they don't.  so char * and int *, etc are all
>         just pointers in RPG.
>...

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.  My own rules for converting C
prototypes to RPG prototypes are as follows:

      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.
  (We have some help for this widening problem coming in a
  future release of RPG)

Barbara Morris


+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.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.