bartop

palmoswerks ARCHIVE
Palm OS programming tips from a (former) CodeWarrior insider

header

Navigation

Search
Home
About
Stories
Stuff I Like
Articles
PilRC
CodeWarrior
palmos.techwood.org
DevTools List
Palm OS Dev FAQ

Minimizing Exception Handling Impact

A user wanted to know if he could rebuild the runtime library to eliminate any code related to exception handling. In practice, you don't need to do this, as long as you take steps to not generate any exception tables in your code, and you don't link against code that generates exceptions.

This works because code that's in CodeWarrior static libraries doesn't get linked into your application unless it is needed. Nothing in the standard startup path uses routines from Exception68K.cp unless one or more of your files has been built with exception handling turned on. You can check your MAP file to see. Turn on map generation in the 68K Linker pref panel.

A basic app will pull in the __dthandler__4MTWKFv and __duhandler__MTWKFv symbols from NWMException.cpp, but these are just "termination" routines that add about 24 bytes to your application.

You might see the Exception68K.cp file in the file list at the top of the map file, but unless there are items in the segment list that are tagged to it, there's no exception handling code linked into your app.

There is one likely avenue for having exceptions in your app. If you use new/delete, you'll pull them in from the runtime library, and new will throw an exception if it can't allocate the memory needed.

To fix this, look at my article at http://www.palmoswerks.com/2001/10/31 about how to declare inline forms of new/delete for your app that won't throw exceptions. You can't just do "new (std::nothrow) foo", since the nothrow version is just setup to catch the exception and then return NULL.

brought to you by weblogger.com


Send feedback to combee@techwood.org
Copyright © 2004 Benjamin L. Combee
Palm OS is a registered trademark of PalmSource, Inc.
Metrowerks and CodeWarrior are registered trademarks of Metrowerks Inc.

The views expressed on this website/weblog are those of mine alone and do not necessarily reflect the views of PalmSource or Metrowerks.

This is a Manila Site

qwertYAK / frobnovich