• Please review our updated Terms and Rules here

Borland C++ 4.0/4.5 - EXE size vs. exception handling/RTTI

alank2

Veteran Member
Joined
Aug 3, 2016
Messages
2,264
Location
USA
Hi Everyone,

So this is a long shot that anyone remembers or even knows about this. WIth Borland C++ 4.0-4.52 (I can't find 4.53 to test though I owned it back in the day), there is a project properties page for exception handling. When I make a simple hello world application, there seems to be no way to turn the exception handling off. It is 40-50K in size instead of the typical 10K size that it should be. Looking at the map file shows that it has a bunch of functions for exception handling which look like they are also pulling in a string class which explains the extra size, but how to disable it? I've tried everything I can think of. I'm surprised is no one noticed this back then.
 
With a quick Google search I found this PDF:

Which on page 114 (last paragraph) says:
RTTI is enabled by default in Borland C++. You can use the -RT command-line option to disable it ( -RT- ) or to enable it (-RT).

Edit: PS, Exception handling (I assume you mean using "try/catch/throw") and RTTI are two different things. I doubt you can "disable" exceptions in C++ as it is a core language feature. If you don't want all the C++ baggage then I suggest to use C instead.
 
Last edited:
I *finally* with some effort figured it out. There are no exception libraries that can be added to a project that prevent increased size. I don't see any information about these in the documentation yet.

1673486631901.png
 
Assuming that NOEH stands for No Exeception Handling and the C, H, L, M, S are indicating the different memory models (W is wide character?). I assume these contain stubs of some sort. No idea which ones.

Can you elborate on what you mean by exeption handling because your initial post isn't very clear.
 
I was wondering why the much larger size in executable size starting with 4.0 - when they added exception handling. They have an option to disable it, but it doesn't prevent parts of it from being linked it for some reason. I'm not sure why they would have to come up with these no exception handling libraries anyway, but they must have had a reason.
 
when you say "exception handling" are you talking about "throw/try/catch" or are you refering to RTTI (RunTime Type Information)?
 
Okay great. So, how is this related to a library? The throw/try/catch is a fundamental part of the C++ language and not something you can just "turn off". The only option is to just not use it but maybe the compiler will always add a specific footprint for this behaviour whether you use the feature or not (which is what it seems like).

RTTI on the other hand is something that is "optional" and as outlined in the documention with the instructions to not include it in your runtime.

It might very well be that these NOEH libraries you found are related to something entrely different, like the OWL framework. Diffecult to tell.
 
>Okay great. So, how is this related to a library? The throw/try/catch is a fundamental part of the C++ language and not something you can just "turn off". The only option
>is to just not use it but maybe the compiler will always add a specific footprint for this behaviour whether you use the feature or not (which is what it seems like).

Maybe this explains why they implemented it the way they did, because C++ made this mandatory and they were giving an option to do it the same as it was previously done before they supported exceptions officially? So, any CPP file will naturally pull in the exception support, but if you don't want it, like version 3.1 or before, you can just include the NOEHx library which will stub out the required calls so they don't link in the exception code and string class.

Fun fact, even compiling a .C file with 4.0 or above will include the extra bulk of the exception code and string class, unless you also use the NOEHx library.

Somehow, I remember the NOEHx libraries from the early 90's, but I don't remember how I found out about them. I've documentation and didn't see anything, but maybe it is in there somewhere and I missed it.

>extra size... so did you strip debug information off the executable?

Always - I usually set up two style sheets (for 4.0 or newer that supports them), one for "Release" and one for "Debug".
 
From the Borland C++ 4.52 Library Reference:

Removing exception handling from the libraries​

The NOEH?.LIB and NOEHW?.LIB 16-bit libraries eliminate the overhead of exception-handling code in the run-time library for users who don't need it and who do not rely on any libraries that require it.

A NOEHxx library must be linked in before the standard run-time library. For command-line tools, this can be accomplished by specifying the appropriate NOEHxx library on the BCC command-line, or making it the first library given to the linker.

For the IDE, add the appropriate library to the project using Add node from the SpeedMenu. To ensure the NOEHxx library is processed before the standard libraries, turn on Show Runtime Nodes in the Options|Environment|ProjectView dialog. From the project window you can move the library up and down using the Alt+<arrow> keys. Be sure the NOEHxx library appears before other standard libraries.

Note . Use NOEHWL.LIB when building DPMI16 programs.
The NOEHxx libraries resolve calls to exception-related compiler helper functions to dummy functions that return appropriate return values. They also restore the pre-exception behavior of operator new to return NULL on out-of-memory conditions. Non-exception enabled versions of setjmp() and longjmp() are also provided.
This is from a HTML version of the documentation I generated by reverse-engineering the DynaText file format (I'll try to release my tools for that sometime "soon"), so it might not be formatted quite right.

Its README.TXT includes text pretty similar to the above plus this extra part:
Limitations:

Note: some features introduced in BC4.0 require exception handling.
These include the string class, BIDS container classes, the standard
OWL libraries, and RTTI.
 
Back
Top