SEC32.hss 1.4 KB

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