[AD] Exception Support for Allegro

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Given Allegro's heavy use of callbacks, wouldn't it
make sense to add exception support to the compiles?
(on gcc)

I've run into this issue before. Heres some code that
will re-produce the problem that would be solved.

BITMAP *load_test(const char *filename, RGB *pal)
{
  throw "test error";
}

int main()
{
  allegro_init();

  try {
    register_bitmap_file_type("ext", load_test, 0);
    destroy_bitmap(load_bitmap("file.ext"));
  } catch(char *err) {
    allegro_message("%s", err);
  }
  
  return 0;
}
END_OF_MAIN()

The solution to this problem is to use gcc's
-fexceptions which aparently has no execution time
overhead.

Quote from gcc:
-fexceptions
Enable exception handling.  Generates extra code
needed to propagate
exceptions.  For some targets, this implies GCC will
generate frame unwind
information for all functions, which can produce
significant data size
overhead, although it does not affect execution.  If
you do not specify
this option, GCC will enable it by default for
languages like C++ which
normally require exception handling, and disable it
for languages like C
that do not normally require it.  However, you may
need to enable this
option when compiling C code that needs to
interoperate properly with
exception handlers written in C++.  You may also wish
to disable this
option if you are compiling older C++ programs that
don?t use exception
handling.

In layman's terms, it would make the dll bigger, but
not have any effect on performance.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/