What Went Wrong

From HI-TECH C for CP/M Fan WIKI(EN)
Jump to: navigation, search

There are numerous error messages that the compiler may produce. Most of these relate to errors in the source code (syntax errors of various kinds and so forth) but some represent limitations, particularly of memory. The two passes most likely to be affected by memory limitations are the code generator and the optimizer. The code generator will issue the message "No room" if it runs out of dynamic memory. This can usually be eliminated by simplifying the expression at the line nominated in the error message. The more complex the expression, the more memory is required to store the tree representing it. Reducing the number of sym- bols used in the program will also help.

Note that this error is different from the message "Can't generate code for this expression" which indicates that the expression is in some way too difficult for the code generator to handle. This message will be encountered very infrequently, and can be eliminated by changing the expression in some way, e.g. computing an intermediate value into a temporary variable.

The optimizer reads the assembler code for a whole function into memory at one time. Very large functions will not fit, giving the error message "Optim: out of memory in _func" where func is the name of the function responsible. In this case the function should be broken up into smaller functions. This will only occur with functions with several hundred lines of C source code. Good coding practice will normally limit functions to less than 50 lines each.

If a pass exits with the message "Error closing file", or "Write error on file", this usually indicates that there is insufficient room on the current disk.

If you use a wordprocessing editor such as Wordstar, ensure that you use the "non-document" mode or whatever the corresponding mode is. The edited file should not contain any characters with the high bit set, and the line feed at the end of the line must be present. Lines should be not more than 255 characters long.

When using floating point, ensure that you use a -LF flag at the END of the command line, to cause the floating point library to be searched. This will cause floating ver- sions of printf and scanf to be linked in, as well as specific floating point routines.

If the non-floating version of printf is used with a floating format such as %f then it will simply print the letter f.

If the linker gives an "Undefined symbol" message for some symbol which you know nothing about, it is possible that it is a library routine which was not found during the library search due to incorrect library ordering. In this case you can search the library twice, e.g. for the stan- dard library add a -LC to the end of the C command line, or -LF for the floating library. If you have specified the library by name simply repeat its name.