× 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: Date procedure
  • From: bmorris@xxxxxxxxxx
  • Date: Fri, 8 Dec 2000 13:21:14 -0500
  • Importance: Normal


Date: Thu, 7 Dec 2000 16:30:45 -0500
From: Contractor1@Parkdalemills.com

Ideally, there should only be one prototype in existence for
any one procedure.

If the procedure is local to the module, (no export keyword
on the P-B spec) then it's probably best to have the prototype
in that module, since it can't be called from outside the
module.

But if procedure is exported, it's best to have the prototype
in a /COPY file, so all the callers and the exporting module
itself can use the same prototype.  That way, if the procedure
changes its return value or parameters:
1. if you forget to change the prototype, you'll find out as
   soon as you try to compile the module containing the
   procedure
2. if you need to change the code for any callers, you find
   out when you compile the modules containing calls to the
   procedure.  (This is where the system isn't perfect -
   you have to remember to recompile all the modules containing
   calls to the procedure.)

If you have multiple prototypes, you don't get any of the
parameter-checking benefits of using prototypes.

(The only time you actually need multiple prototypes is when
you have callers in different languages.)

Here endeth the lesson :-)

But here beginneth a couple of tips:

1. You can use preprocessor directives to keep the prototypes and
   procedures in the same source file.  I didn't invent this -
   I first heard about it on one of the magazine forums.  Assume
   this module is MOD1:

   |   /if defined(COMPILING_MOD1)
   |  put the first part of your non-prototype code here, h spec,
   |  f specs etc
   |   /endif
   |
   |  here, put any constants you want your callers to use, and
   |  prototypes for all your exported procedures, including
   |  your main procedure if there is one
   |
   |   /if not defined(COMPILING_MOD1)
   |   /eof
   |   /endif
   |
   |  put the rest of your module code here

   When you compile the actual module, specify DEFINE(COMPILING_MOD1)
   on the CRT command.  Then /COPY MOD1 in your callers.
   Alternative, instead of "defined(COMPILING_MOD1)", use
   "not defined(COPYING_PROTOTYPES)", and in your callers, code this:
      /define COPYING_PROTOTYPES
      /copy MOD1

2. You can combine a C and RPG include in the same source file:

    ....+....1....+....2....+
   |#if 0
   |     D put your RPG code here
   |      /eof
   |#endif
   |      put your C code here

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-Ups:

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.