Quote:
so what is the benefit of using #if 0? only as a note for other usage?
the benefit is that a single source code file can have more than 1 usage.
"#if" is a preprocessor command for
conditional compilation.
Example:
- C/C++ have no language provision for modern things like unit testing or debugging. With preprocessor directives, the conditional code can be included/excluded as you want.
- It allow keeping different versions of your code, as you refine it and want to keep old versions.
- In order to test correctness of your code, you need special code that you don't want in production code. Conditional compilation is the simple solution.
- You have crafted some code to solve a complicated problem and want to refine the solution, you can either trow away first solution and start a new 1, but you can't use first solution since you killed it, either you use conditional compilation to switch between solution s as you need.