02.03.2014 Views

vxworks programmer's guide.pdf - DAQ Plone Site

vxworks programmer's guide.pdf - DAQ Plone Site

vxworks programmer's guide.pdf - DAQ Plone Site

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5<br />

C++ Development<br />

consult any standard C++ reference (a good one is Stroustrup, The C++<br />

Programming Language, Third Edition). For documentation on the GNU<br />

implementation of the Iostream library see<br />

5.3.1 Language Features<br />

We support many but not all of the new language features contained in the recently<br />

approved ANSI C++ Standard. Tornado 2.0 has support for exception handling<br />

and run-time type information, as well as improved template support. We do not<br />

yet support the namespace feature although the compiler will accept (and ignore)<br />

references to the std namespace.<br />

5<br />

Exception Handling<br />

Our C++ compiler supports multithread safe exception handling by default. To<br />

turn off exception handling support use the -fno-exceptions compiler flag.<br />

Using Exceptions<br />

You may have code which was designed around the pre-exception model of C++<br />

compilation. Your calls to new may check the returned pointer for a failure value<br />

of zero, for example. If you are worried that the exception handling enhancements<br />

in this release will not compile your code correctly, you could adhere to the<br />

following simple rules:<br />

■<br />

■<br />

Use new (nothrow).<br />

Do not explicitly turn on exceptions in your Iostream objects.<br />

■<br />

Do not use string objects or wrap them in “try { } catch (...) { }” blocks.<br />

These rules derive from the following observations:<br />

■<br />

The GNU Iostream does not throw unless IO_THROW is defined when the<br />

library is built and exceptions are explicitly enabled for the particular Iostream<br />

object in use. The default is no exceptions. Exceptions have to be explicitly<br />

turned on for each iostate flag that wants to throw.<br />

■<br />

The STL does not throw except in some methods in the basic_string class (of<br />

which string is a specialization).<br />

237

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!