1234567891011121314151617181920212223242526272829303132333435 |
- [Main]
- Title=Conditional Uses
- [Top]
- There are three general reasons to use a conditional.
- <UL>
- <LI>
- A program may need to use different code depending on the machine or
- operating system it is to run on. In some cases the code for one
- operating system may be erroneous on another operating system; for
- example, it might refer to data types or constants that do not exist on
- the other system. When this happens, it is not enough to avoid
- executing the invalid code. Its mere presence will cause the compiler
- to reject the program. With a preprocessing conditional, the offending
- code can be effectively excised from the program when it is not valid.
- <BR><BR>
- </LI>
- <LI>
- You may want to be able to compile the same source file into two
- different programs. One version might make frequent time-consuming
- consistency checks on its intermediate data, or print the values of
- those data for debugging, and the other not.
- <BR><BR>
- </LI>
- <LI>
- A conditional whose condition is always false is one way to exclude code
- from the program but keep it as a sort of comment for future reference.
- </LI>
- </UL>
- Simple programs that do not need system-specific logic or complex
- debugging hooks generally will not need to use preprocessing
- conditionals.
- In TIGCC, conditionals are useful to select appropriate constants depending
- on which calculator and operating system the program is intended to run on,
- and to enable or disable certain features.
|