Revision history for TutConditionalCompilation


Revision [22189]

Last edited on 2018-02-07 16:11:27 by sancho3
Additions:
The scope of this tutorial is a limited one, but this method is used by professionals. It makes life easy when programming.
//Last reviewed by ""sancho3" on February 07, 2018 Notes: Removed dead links//
Deletions:
The scope of this tutorial is a limited one, but this method is used by professionals. It makes life easy when programming. I have used this method in my own code. To see this code in action, view the source [[http://avinash.apeshell.net/stuff/ship/flyaround.bas|here]].
http://avinash.apeshell.net


Revision [20684]

Edited on 2016-02-10 16:14:47 by DkLwikki [Update link format]
Additions:
//Written by aetherFox for [[http://petesqbsite.com/sections/express/issue9/index.html#compilation|QB Express Issue #9]]//
**Note** you do not need the comment after the ##[[KeyPgEndif|#endif]]##, but is it good practice.
Basically, the above code checks to see whether ##DEBUG## has been defined, and if it has, then the code between the ##[[KeyPgPpifdef|#ifdef]]...[[KeyPgPpendif|#endif]]## will be executed. While this may seem silly, the uses this has are amazing. If you simply remove one line at the top of your program (##[[KeyPgPpdefine|#define]] DEBUG##), then all the 'debug code' that you've added won't be sent to the compiler -- the preprocessor removes it, reducing the bloat of the final executable.
The ##[[KeyPgPpundef|#undef]]## directive is a way of 'undefining' something, in this case ##DEBUG##. While it is strictly not needed (just commenting out the line '##[[KeyPgPpdefine|#define]] DEBUG##' is enough), it makes the code much clearer, and has other uses:
While not the most useful example, this demonstrates the use of another directive: ##[[KeyPgPpifndef|#ifndef]]##. This directive will cause the code to be compiled if the symbol is not defined.
Much like a normal programming language, the sense of the conditional can be reversed using a variant of else, ##[[KeyPgElse|#else]]##:
The scope of this tutorial is a limited one, but this method is used by professionals. It makes life easy when programming. I have used this method in my own code. To see this code in action, view the source [[http://avinash.apeshell.net/stuff/ship/flyaround.bas|here]].
Deletions:
//Written by aetherFox for [[http://petesqbsite.com/sections/express/issue9/index.html#compilation QB Express Issue #9]]//
**Note** you do not need the comment after the ##[[KeyPgEndif #endif]]##, but is it good practice.
Basically, the above code checks to see whether ##DEBUG## has been defined, and if it has, then the code between the ##[[KeyPgPpifdef #ifdef]]...[[KeyPgPpendif #endif]]## will be executed. While this may seem silly, the uses this has are amazing. If you simply remove one line at the top of your program (##[[KeyPgPpdefine #define]] DEBUG##), then all the 'debug code' that you've added won't be sent to the compiler -- the preprocessor removes it, reducing the bloat of the final executable.
The ##[[KeyPgPpundef #undef]]## directive is a way of 'undefining' something, in this case ##DEBUG##. While it is strictly not needed (just commenting out the line '##[[KeyPgPpdefine #define]] DEBUG##' is enough), it makes the code much clearer, and has other uses:
While not the most useful example, this demonstrates the use of another directive: ##[[KeyPgPpifndef #ifndef]]##. This directive will cause the code to be compiled if the symbol is not defined.
Much like a normal programming language, the sense of the conditional can be reversed using a variant of else, ##[[KeyPgElse #else]]##:
The scope of this tutorial is a limited one, but this method is used by professionals. It makes life easy when programming. I have used this method in my own code. To see this code in action, view the source [[http://avinash.apeshell.net/stuff/ship/flyaround.bas here]].


Revision [10432]

The oldest known version of this page was created on 2007-07-31 11:47:22 by JeffMarshall [Update link format]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode