Does "#if 1 func1 #else func2 #endif execute func1 during executation?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mr. Ken

    #1

    Does "#if 1 func1 #else func2 #endif execute func1 during executation?

    In the file I received, it defines two versions of same function with such
    statement.
    Is it during compilation, func1 will be used?

    #if 1
    func1.....
    #else
    func1.....
    #endif

    Sorry for the silly question but I am a little confused now.



  • Bart

    #2
    Re: Does "#if 1 func1 #else func2 #endif execute func1 during executation?

    Mr. Ken wrote:
    In the file I received, it defines two versions of same function with such
    statement.
    Is it during compilation, func1 will be used?
    >
    #if 1
    func1.....
    #else
    func1.....
    #endif
    >
    Sorry for the silly question but I am a little confused now.
    Here the first version (#if 1) will be compiled and the second version
    (#else) will be ignored. The function will not be used at compile time.
    This is just a way to compile a different version of the function.

    Regards,
    Bart.

    Comment

    • Mr. Ken

      #3
      Re: Does "#if 1 func1 #else func2 #endif execute func1 during executation?


      "Bart" <bart.kowalski@ gmail.comwrote in message
      news:1157533929 .795501.57050@b 28g2000cwb.goog legroups.com...
      Mr. Ken wrote:
      In the file I received, it defines two versions of same function with
      such
      statement.
      Is it during compilation, func1 will be used?

      #if 1
      func1.....
      #else
      func1.....
      #endif

      Sorry for the silly question but I am a little confused now.
      >
      Here the first version (#if 1) will be compiled and the second version
      (#else) will be ignored. The function will not be used at compile time.
      This is just a way to compile a different version of the function.
      >
      Regards,
      Bart.
      >
      Thank you Bart.



      Comment

      • bharath.donnipad@gmail.com

        #4
        Re: Does &quot;#if 1 func1 #else func2 #endif execute func1 during executation?


        Mr. Ken wrote:
        "Bart" <bart.kowalski@ gmail.comwrote in message
        news:1157533929 .795501.57050@b 28g2000cwb.goog legroups.com...
        Mr. Ken wrote:
        In the file I received, it defines two versions of same function with
        such
        statement.
        Is it during compilation, func1 will be used?
        >
        #if 1
        func1.....
        #else
        func1.....
        #endif
        >
        Sorry for the silly question but I am a little confused now.
        Here the first version (#if 1) will be compiled and the second version
        (#else) will be ignored. The function will not be used at compile time.
        This is just a way to compile a different version of the function.

        Regards,
        Bart.
        >
        Thank you Bart.
        Code under #if 1 always compiles and gets embedded in to object file.
        You may find #if 0 in some code where in the code under it will not
        compile.

        - Bharath

        Comment

        Working...