On Thu, Jan 08, 2009 at 08:48:46AM -0500, Jeremy Kolb wrote: > >> I believe it's possible to use a "safe" subset of C++ such that no >> libraries are required. If you avoid exceptions, RTTI, the C++ standard >> library functions, and new/delete, you should be able to avoid depending >> on the library in most toolchains, and in some cases you may be able to >> use some of these features (e.g. you can overload the new and delete >> operators to avoid depending on the library versions, but then you have >> to do some linker jiggery-pokery to avoid symbol clashes). The other >> problem is that you then have to work out the magic incantations for >> each compiler/linker to avoid it linking in libstdc++ or equivalent >> anyway. >> Bruce > > WRT new and delete most compilers provide a nothrow_t version which will > not throw any exceptions but return NULL on failure similar to malloc.
This is true, but exceptions are only half the problem. The actual allocation and deallocation operations of new and delete are implemented in the functions ::operator new and ::operator delete (or variants thereof for nothrow versions), and these functions part of libstdc++ (at least one my particular system). So if you intend to use new/delete, you need some cleverness so that a) you have your own versions of these symbols available to your C++ code (fairly easy, just overload the global new/delete operators) b) your versions don't cause symbol clashes if your library is linked into some program alongside libstdc++ (more difficult depending on how much you care about portability - you need to tell the linker not to export the symbols, and the mechanisms for doing that are not standardised). Regards Bruce -- Dr Bruce Merry bmerry <@> gmail <.> com http://www.brucemerry.org.za/ http://blog.brucemerry.org.za/ A good day for making firm decisions. Or is it? ------------------------------------------------------------------------------ Check out the new SourceForge.net Marketplace. It is the best place to buy or sell services for just about anything Open Source. http://p.sf.net/sfu/Xq1LFB _______________________________________________ Mesa3d-dev mailing list Mesa3d-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mesa3d-dev