Exploring C11 and C++14

Exploring C11 and C++14

IAR Embedded Workbench for Arm delivers support for the latest C11 and C++14 language standards. But how to make use of these standards? Explore its capabilities in this article with an example project included.

The C language standard ISO/IEC 9899:2012 and C++ standard ISO/IEC 14882:2015 or just better C11 and C++14 have been around for a while. Support for these standards is available from version 8.10 of IAR Embedded Workbench for Arm.

C++ has influences from lot of other languages. Started as a project to improve C in 1979 and was named C with classes and finally changed name to C++ in 1983. The first commercial release was in 1985.

The short story is that C++14 is ”based” on C11 that attempts to fix what was broken in C99. C11 is a superset of C99 and is more compatible with C++. This makes the mix of C and C++ easier. In real applications we have the chip vendors providing their low level drivers in C. If you want to develop your embedded application in C++ you end up in doing a mix from the libraries provided in C and your application written in C++. This use case of mixing C and C++ is very well supported by IAR Embedded Workbench. The Auto (extensions-based) language selection is recommended in this case. 


So what’s new?

I will not go through all features in detail but I thought I would list some of them.


  • Type-Generic Functions
  • Memory Alignment Control
  • The _Noreturn Function Specifier
  • Unicode Support
  • Static Assertions
  • gets() Removed
  • Macros
    • complex values
    • subnormal floating point numbers
    • and much more


  • Automatic type inference
  • New binary constants
  • The [[deprecated]] and[[noreturn] Attributes
  • Generic Lambdas

And also:

  • Move semantics
  • Range based for-loops
  • New string literals for Unicode encoded strings
  • Atomics
  • Null pointer constant
  • Lots of other smaller features

How is my current project affected?

Porting your C or C++ application should be pretty straightforward. The most dramatic change is that the Embedded C++ and Extended Embedded C++ language and library mode is no longer supported. This is due to the obvious reason that the own subset of C++ can be defined by the end user and extended to the full C++.

When porting an Embedded C++ application it can be a major issue that the C++ library symbols now reside in the std namespace. The user must then either prepend each reference to such symbols with std:: or must insert the following line after the include directives but before any C++ library symbol references, in each C++ source file or suitable header file(s):

using namespace std;

Also, a side effect of dropping support for the old Extended Embedded C++ STL is that STL can only reside in the default memory and operate on default pointers. For more information, have a look in the C/C++ Development Guide for Arm, chapter “Porting code from EC++ or EEC++."

Trying the new features

Many customers have asked us to upgrade our tools to C11 and C++14. When you switch to C11 and C++14 you will have access to a safer standard and get access to the performance benefits for free, for example the move semantics that will reuse and optimize the way of copying, aside of auto, atomic and so one. All the new features will also help you to be more productive and have smaller and more readable code.

In order to give you a chance to quickly try some of the new features, for example attributes, binary literals, digit separators, automatic type inference and range based for-loops, we are providing you with an example project for C++14. To be able to run the example, you need version 8.10 of IAR Embedded Workbench for Arm. You can download the example file here.

Try the new C++ features in the following five steps:

  1. Open the UsingCPlusPlus.eww workspace with File>Open Workspace
  2. Choose Project>Make to compile and link your application
  3. Choose Project>Download and Debug to start C-SPY Simulator
  4. Choose View>Terminal I/O to open the Terminal I/O window
  5. Click the Go button () to resume the execution.

Monitor the text information printed in the Terminal I/O and correlate the use cases with the source code from UsingClasses.cpp. Feel free to step in, step over, run and reset the Simulator in the debug toolbar buttons.

example project

You can also find additional information in the doc folder and file UsingCpp.ENU.html regarding the complete C++ example. 

© IAR Systems 1995-2017 - All rights reserved.