DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Writing drivers in C++

Exception handling

C++ drivers should use the conventional error handling facilities discussed in ``Error handling''. Do not use exception handling within a device driver. Specifically, the throw, try, and catch keywords are not allowed. This is not an issue for SCO SVR5 2.X C++ and SCO OpenServer 5 C++, because those compilers do not implement exception handling.

This restriction is necessary because of the large execution-time overhead incurred when an exception is thrown, and the fairly large amount of storage overhead incurred whether an exception is thrown or not. Such overhead can severely degrade the performance of the system and so are undesirable in kernel code. Moreover, the implementation of exception handling relies on the cooperation of the runtime dynamic linker, which is not present in the kernel environment.

Because exceptions will not be thrown within a driver, SVR5 C++ driver code should be compiled with the following (undocumented) compiler option to ensure that no unnecessary and wasteful exception handling information is generated into data sections, and to ensure that no code optimization is suppressed because of the indirect effects of exception handling constraints:

   CC -Wf,--no_exceptions

© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005