5d0 Subj : Re: try/finally in C++ To : borland.public.cpp.borlandcpp From : Dennis Jones Date : Thu Jul 08 2004 02:28 pm "Thomas Maeder [TeamB]" wrote in message news:m2vfgy4gi3.fsf@madbox2.local... > "Dennis Jones" writes: > > > Does anyone know if there is a way to get try/finally functionality from the > > Borland C++ compiler (version 5.0x) when compiling C++ code? BC 5.0x only > > seems to support __try/__finally in C mode (not C++), and in C++ mode, it > > only seems to support try/catch (no "finally"). I'd really like to get > > something like the try/__finally support that is available in BCB. Is this > > possible with the older 5.0x compiler? > > I don't think so. > > I also don't see why finally should be needed in Borland C++. This extension > was added along with VCL support, because VCL objects don't behave like real > C++ objects when it comes to cleaning up after themselves. > > The native C++ approach for objects to properly release "their" resources > is RAII (Resource acquisition is initialization): wrap each allocated > resource into an object that solely exists for releasing the resource once > it's no longer needed. > > Google for "C++ RAII" if you want to know more. Unfortunately, I am dealing with some old embedded (static) SQL code that gets compiled by a SQL compiler into C++ code, and so it doesn't lend itself well to using RAII. Thanks anyway, - Dennis . 0