Documentation Archive Developer
Search

ADC Home > Reference Library > Technical Q&As > Carbon > Design Guidelines >

Are there any OSStatus values I can use in my programs?


Q: My code is careful about runtime errors, but sometimes I need to generate an error which does not correspond to anything in the system. Are there any OSStatus values I can use in my programs without fear of colliding with Apple values (past, present, or future)?

A: Yep. You can use any value from 1000 to 9999, inclusive. We've verified that our internal registry of error values in use by past and present versions of the system contains no values in this range, and we've now registered this range for use by developers so that future versions of the system won't return any of these values.

Don't allow any of these error values to propagate into code whose interface you don't control. If you define the value 1000 to mean something specific to your program, don't expect the system or another program to understand unless you also control that other program.

Furthermore, don't attempt to reserve values within the developer range, even if you intend to use those values for a public interface, such as a Code Fragment Manager shared library or a Component Manager component. There is no registry for values within the developer range, and thus there is no way to avoid collisions with values used by other developer programs.

Another example of a public interface would be a plug-in architecture; potential clients of such an architecture may want to reuse code that already has meanings associated with some values in the developer range. You probably want to minimize the chance that potential plug-in developers will need to expend effort to resolve error code collisions. Similarly, if you are developing a plug-in, don't return errors within the developer range to your host program unless you know your host expects them.

Finally, if you're presently using other values in your program and hoping to get away with it because they're not in <MacErrors.h>, don't. Apple presently reserves all values which are not in the developer range.

[Nov 22 1999]