Re: Exceptions & OPIE?
Manuel Klimek <[email protected]>
| Newsgroups | gmane.comp.handhelds.opie.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, the price you have to pay for exceptions in terms of binary size is quite remarkable - this is why qt comes without exceptions and probably the same reason why opie doesn't use exceptions. The problem is that if exception handling is enabled, the compiler has to assume that an exception can be thrown for every function call that is not inlined, thus injection so called 'unwinding code' into the executable, which makes the binary bigger. And gcc uses rtti for the exception catching code, so all 'thrown' objects will export their rtti, too, which is again a considerable amount of code size. But it is often worth the binary size in terms of code robustness, and there are ways to tell gcc that a certain much used function doesn't throw an exception, but this requires some experience for all but the simplest functions. If you write a library though, it's not just the size of _your_ library that matters - if an exception may 'fall through' one of your library calls, all programs using your library must be compiled with exception handling enabled - and not every developer thinks exceptions are worth the bloat in binary size. This is a topic you have to investigate carefully before making a decision if you want your library to be accepted widely. Oh, and gcc >= 4.1 has much better code size optimizations (and the possibility to handle symbol exports manually), so C++ code size is getting better in the open source world, even without loosing some of C++ strongest features like exception handling and rtti ;-) Hope I could help Manuel On Saturday 10 June 2006 20:21, Patrick Hoffmann wrote: > On Sat, 10 Jun 2006 19:47:32 +0200, Erik Hovland <[email protected]> wrote: > > I don't know specifically why Opie uses that flag. But I do know that > > generally gcc native exceptions can expand the size of binaries on > > embedded systems like arm and powerpc. > > Hm - I have to compile for arm. So I should mind that ;( > > > Is there any way that you could substitute macros for your exception > > handling that would allow for exceptions when present and melt away when > > not? > > I can replace the exceptions (only a few). But I'm interested, because I'm > workin on a library that uses exceptions and it would be great if this > wont be a problem on embedded systems. Do you know where I can get more > information about this issue? May be... a document? > > Thanx for your help, Erik. _______________________________________________ http://opie.handhelds.org/cgi-bin/moin.cgi/DeveloperWikiIndex Opie-devel mailing list [email protected] https://handhelds.org/mailman/listinfo/opie-devel