Software Directory: EC++ Shrinks Headaches

Dec. 9, 2002
Availability and power have driven C++'s rocketing popularity. Unfortunately, the massive size of the C++ specification can be daunting to developers and compiler writers alike. Difficulty in understanding the specification and its implementation...

Availability and power have driven C++'s rocketing popularity. Unfortunately, the massive size of the C++ specification can be daunting to developers and compiler writers alike. Difficulty in understanding the specification and its implementation with specific compilers can lead to the generation of unexpected code that may not be needed or tested.

The Embedded C++ (EC++) standards proposal is designed to trim the C++ specification to a more manageable size. It eliminates many of the features that may be unnecessary in the average embedded environment. As a proper subset, it won't contain additional syntax to extend the C++ standard.

Design goals for the specification include making the specification as small as possible while retaining C++'s object-oriented features, as well as avoiding features that use excessive amounts of memory. It also aims to avoid features that produce unpredictable response times, and to have all EC++ code be ROMable.

The specification's amendment style of the ISO/ANSI C++ Draft Standard is registered as SC22/WG21/N1037. The specification is a bit hard to read because it indicates what parts of the C++ standard are omitted versus a complete definition of what is included. For example, the Reserved But Excluded list above shows the C++ keywords that can't be used within an EC++ program, because the associated feature isn't supported. The keywords are still reserved, so they can't accidentally be used as variable or function names. This means that an EC++ application can always be compiled using a standard C++ compiler. The only difference is that a standard will not check for reserved but excluded names and features.

Doing Without: One major feature eliminated in EC++ from C++ is exception handling using catch and throw. The reason for this is twofold. First, it's difficult to estimate the time needed for error handling. Plus, the amount of memory required for exception handling is unknown. That said, exception handling is still a very nice C++ feature. Therefore, developers will have to carefully consider what EC++ aspects are most suitable for their particular embedded applications.

Templates and multiple inheritance are two other major C++ features that are absent from EC++. Although they are handy for generic classes and functions, it's easy to misuse templates. This results in unexpected code that can mushroom the size of an application, making it exceed the limited memory available in most embedded applications.

Multiple inheritance is a useful feature in some instances, yet it's rarely utilized by the majority of C++ programmers. It has sizable implications for initialization and casting. If used improperly, applications with multiple inheritance can be hard to maintain or reuse. Eliminating multiple inheritance also makes EC++ easier to learn. Some of the removed features will impact runtime libraries that can be employed with EC++. For example, the Standard Template Library (STL) can't be used with EC++ because templates aren't supported.

Advantages: Paring down C++ makes EC++ easier to learn and simplifies maintenance of EC++ applications. Compilers can be more aggressive in their optimizations because EC++ applications will not require various runtime features. In some cases, EC++ compilers can generate programs that are significantly smaller than the same program compiled via generic compiler C++ settings. Moreover, most implementations can apply EC++ restrictions selectively.

Not surprisingly, EC++ has garnered a significant following in the C++ vendor community. It has changed the minds of a number of programmers that would otherwise utilize C, or even an assembler, for embedded applications.

www.caravan.net/ec2plus

RESERVED BUT EXCLUDED
catch
const_cast
dynamic_cast
export
mutable
namespace
reinterpret_cast
static_cast
template
throw
try
typeid
typename
using
wchar_t
About the Author

William G. Wong | Senior Content Director - Electronic Design and Microwaves & RF

I am Editor of Electronic Design focusing on embedded, software, and systems. As Senior Content Director, I also manage Microwaves & RF and I work with a great team of editors to provide engineers, programmers, developers and technical managers with interesting and useful articles and videos on a regular basis. Check out our free newsletters to see the latest content.

You can send press releases for new products for possible coverage on the website. I am also interested in receiving contributed articles for publishing on our website. Use our template and send to me along with a signed release form. 

Check out my blog, AltEmbedded on Electronic Design, as well as his latest articles on this site that are listed below. 

You can visit my social media via these links:

I earned a Bachelor of Electrical Engineering at the Georgia Institute of Technology and a Masters in Computer Science from Rutgers University. I still do a bit of programming using everything from C and C++ to Rust and Ada/SPARK. I do a bit of PHP programming for Drupal websites. I have posted a few Drupal modules.  

I still get a hand on software and electronic hardware. Some of this can be found on our Kit Close-Up video series. You can also see me on many of our TechXchange Talk videos. I am interested in a range of projects from robotics to artificial intelligence. 

Sponsored Recommendations

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!