P.J. Plauger said:
Right. But sometimes it works *well enough*.
I remember well the 80's. Lots of people ported unix utilities to 16 bit
DOS. Those utilities were designed for 32 bit flat code, and whether
they worked "well enough" on DOS was certainly a matter of opinion. They
usually got stomped by utilities and applications that were custom
crafted for the quirks of 16 bit computing.
I ask the question because I don't know of any 16 bit C++ compiler that
supports either modern templates or exception handling, besides Digital
Mars C++.
Not necessarily. You can trade time vs. space for exception handling, and
I've seen both extremes.
The two main schemes for doing exception handling are:
1) Microsoft style, where runtime code is inserted to keep track of
where one is in a table of destructors that would need to be unwound
2) Linux style, where the PC is compared against a static table of
addresses to determine where in the table one is
Both involve the addition of a considerable chunk of code (1) or data (1
and 2). Under (2), that chunk consists of data that isn't actually
needed unless an exception is thrown. This is an efficient
implementation under a system that has demand paged virtual memory,
where executables' pages are only loaded from disk if the address is
actually referenced.
This is not the case for 16 bit DOS, which *always* loads the entire
executable into memory. DOS doesn't have demand paged virtual memory. 32
bit DOS extenders do add demand paged virtual memory, but only for 32
bit code, not 16 bit.
Hence, the exception handling bloat is always taking away space from
that precious 640Kb of memory. I suppose it is possible for the
compiler/linker to write the exception handling tables out to a separate
file, but I've never heard of an implementation that did that.
Ah, I see part of the communication gap here. By STL *you* mean "the
Standard C library", while *I* mean "that set of containers and algorithms
based heavily on the Hewlett-Packard Standard Template Library".
I mean STL as in "C++ Standard Template Library."
We avoid
the iostreams bloat by offering EC++ (as well as the full Standard C++
library), which looks more like the original cfront iostreams than the
full bore templated and internationalized thing that got standardized.
Our Abridged Library consists of EC++ with STL bolted on.
Digital Mars C++ for 16 bits does offer both of the two older
implementations of iostreams (iostreams went through a couple major
redesigns before being standardized). These work tolerably well on 16
bit platforms, but they are not Standard C++ iostreams by any stretch of
the imagination.
Well, it was by us. I agree that stdio can be smaller, particularly if
you use a bespoke printf that omits floating-point when you don't need
it. But once again, EC++ has proved repeatedly to be *small enough*.
From
http://www.dinkumware.com/embed9710.html:
-----------------------------------
What's Not in Embedded C++
Embedded C++ is a library specification and a minimum language
specification. The minimum language specification is a proper subset of
C++, omitting:
multiple inheritance and virtual base classes
runtime type identification
templates
exceptions
namespaces
new-style casts
------------------------------------
EC++ being practical for 16 bit targets does not imply that templates
and exception handling are. EC++ is kinda what C++ was back in 1991 or
so, when it worked well on 16 bit targets.
Do you know anyone using STL (Standard Template Library) for 16 bit X86
programming? I would be surprised if there were any. I looked around on
the Dinkumware site, but didn't find anything specifically mentioning 16
bit support or any particular 16 bit C++ compilers, but perhaps I missed it.
-Walter Bright
www.digitalmars.com C, C++, D programming language compilers