# Programming Notes

This section discusses some frequently encountered problems. It covers:

- Using Relative Pathnames
- Hints on Error Checking and Other Advice

## Using Relative Pathnames

Applications should always use pathnames relative to the location from which the application boots.

For example, during development an application boots from /remote. If artwork is located in $boot/art.... , the program should refer to those files as art/.... During development, the pathname is then resolved to /remote/art since the program booted from /remote.

A title should use $boot and other aliases explicitly only in cases where an absolute path is needed because the program would not know how to resolve a relative pathname. Generally, all programs should be able to resolve a relative pathname, with the current location being the point from which the program was entered.

Warning: Never use /remote in a pathname; it won't be available on an end-user machine.

## Hints on Error Checking and Other Advice

Here are some common problems and advice on how to avoid them:

- Check all function return values. Make sure a function never exits the program if an error results and that returned pointer values are not `NULL`.

- Use printf() to facilitate debugging. The `printf()` statements in your program statements are displayed in the Debugger Terminal window when you run the application in Debugger mode. The`printf()` statements are dropped when you run in stand-alone mode.

  Note: Once you have generated a clean cdrom.image file, eliminate the `printf()` statements for a slightly more efficient title.

- Don't use OpenMacLink(). The function is obsolete.

- Read an integral number of blocks. When reading files from the CD-ROM, you must read an integral number of disc blocks. For example, if CMD_Status reports that the blocksize is 2048, and the file size is 3277 bytes, you must read 4096 bytes.

- Don't forget to recompile and retest. If you changed your application don't forget to recompile it and test it once more.