On 10/17/06, Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx> wrote:

> The only other way I have seen it done is by a "/if
> defined(TheFollowingIsCommentedOut) and /Endif" statements.  Is there
> another way to do it?

I don't understand why you wouldn't want to use that technique.  It
accomplishes the same thing as /* and */, in a very simple, efficient

Sure, you could use the editor's capability to insert "//" in front of
every line of code -- that's not hard to do -- but it's a pain when it
comes time to re-enable the code.  with IF DEFINED it can be easily

For example, do something like this:

   /if defined(EXPERIMENTAL_CODE)

   ... all of "commented out" code is here


Assuming that "EXPERIMENTAL_CODE" isn't defined, the code will be ignored
by the compiler, and therefore won't be compiled into the program.

If you like, you can even enable it on a per-compile basis by doing this:


You can create any "if defined" condition name that you like.  I often
have programs like "/if defined(EXCLUDE_THIS_CODE)" to make it clear that
I intended to disable the code so that the next guy won't be confused
about whether to enable/disable the define condition.

Of course, it's also easy to simply delete the /IF and /ENDIF lines if you
want to re-enable it permanently.

What is it about this technique that you don't like?

it is hard to make a practical case against ifdefs, I just dont like
that they make it harder to do a static analysis of the code. Where
you parse the code and report the usage of fields, procs, files, ...
C is a great language, but because of the use of its extensive macro
features, C code can be very hard to work with.


This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 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].