conditional compilation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stmfc
    New Member
    • May 2007
    • 65

    conditional compilation

    in C and C++ conditional compilation is very useful for debuging.
    (using debugging MACROs)

    java does not support conditional compilation. what can we use in java
    to replace MACRO usage of C/C++ ?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by stmfc
    in C and C++ conditional compilation is very useful for debuging.
    (using debugging MACROs)

    java does not support conditional compilation. what can we use in java
    to replace MACRO usage of C/C++ ?
    There's no need for macros in Java.

    Why would you like to have conditional compilation?

    Comment

    • kreagan
      New Member
      • Aug 2007
      • 153

      #3
      Originally posted by stmfc
      in C and C++ conditional compilation is very useful for debuging.
      (using debugging MACROs)

      java does not support conditional compilation.
      This comment is assuming you wish to use conditional compilation for environment changes such as simulation and non simulation runs. (I hope that make sense).

      You can implement conditional compilations through interfaces, I'm guessing.
      Use a text file to load different interfaces.

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by kreagan
        This comment is assuming you wish to use conditional compilation for environment changes such as simulation and non simulation runs. (I hope that make sense).

        You can implement conditional compilations through interfaces, I'm guessing.
        Use a text file to load different interfaces.
        There's a small compiler facility: if the condition of an if statement is provably
        false, the entire if statement doesn't generate any code at all:

        Code:
        public class Foo {
           private static final boolean DEBUG= false;
           ...
           public void bar() {
              if (DEBUG) {
                 // no code will be generated here
              }
           }
        }
        kind regards,

        Jos

        Comment

        • kreagan
          New Member
          • Aug 2007
          • 153

          #5
          Originally posted by JosAH
          There's a small compiler facility: if the condition of an if statement is provably
          false, the entire if statement doesn't generate any code at all:

          Code:
          public class Foo {
             private static final boolean DEBUG= false;
             ...
             public void bar() {
                if (DEBUG) {
                   // no code will be generated here
                }
             }
          }
          kind regards,

          Jos
          Very Nice. Thank you.

          Comment

          Working...