0

What is the advantage of using

#if (expression)
statement
#endif

instead of

if (expression){
statement
 }

?

S. Hesam
  • 5,266
  • 3
  • 37
  • 59
  • Well, the disadvantage is twice as many builds to maintain. – Bathsheba Jan 02 '19 at 18:46
  • 1
    the first can produce no code at all, that helps to have a code comparable only in some conditions, for instance only on windows but not on linux etc – bruno Jan 02 '19 at 18:48
  • 1
    Conditional compilation with the preprocessor directive `#if` happens at compile-time. The `if` statement is done at run-time. – Some programmer dude Jan 02 '19 at 18:48
  • 2
    Possible duplicate. Check this link [Advantages of Conditional Compilation](https://stackoverflow.com/questions/17007241/advantages-of-conditional-preprocessor-over-conditional-statements) – Shiva2794 Jan 02 '19 at 18:48
  • `if (expression)` is well defined when `expression` involves FP math. `#if (expression)` is not. – chux - Reinstate Monica Jan 02 '19 at 18:59

0 Answers0