Conditional Compilation
-
Hello, I have a piece of code that should be subject to conditional compilation. I'm trying to compare the use of a conditional directive vs. using an if-condition over a const variable. The second approach looks safer from compilation perspective, but the first one has its advantages (e.g. save memory by not declaring unused variables). I'd appreciate your help on best practices regarding this issue...
Many thanks to all helpful guys here in CP! I really appreciate your help. :rose: Know me better
-
Hello, I have a piece of code that should be subject to conditional compilation. I'm trying to compare the use of a conditional directive vs. using an if-condition over a const variable. The second approach looks safer from compilation perspective, but the first one has its advantages (e.g. save memory by not declaring unused variables). I'd appreciate your help on best practices regarding this issue...
Many thanks to all helpful guys here in CP! I really appreciate your help. :rose: Know me better
Another alternative is to make it configurable. It depends on just what it is you're trying to do.
-
Another alternative is to make it configurable. It depends on just what it is you're trying to do.
Yes, but I don't need that level at the moment. Additionally, making it configurable doesn't allow the compiler to do certain optimizations. For example, checking a const variable which is statically known to be either true or false gives the compiler an opportunity to optimize the check away, and keep only the relevant code (with unreachable code detected warning).
Many thanks to all helpful guys here in CP! I really appreciate your help. :rose: Know me better
-
Yes, but I don't need that level at the moment. Additionally, making it configurable doesn't allow the compiler to do certain optimizations. For example, checking a const variable which is statically known to be either true or false gives the compiler an opportunity to optimize the check away, and keep only the relevant code (with unreachable code detected warning).
Many thanks to all helpful guys here in CP! I really appreciate your help. :rose: Know me better
Then use conditional compilation.