Skip to main content Skip to local navigation

C++ on Microcontrollers, Babysteps

C++ on Microcontrollers, Babysteps

Having watched some of Kate Gregory's tutorials on Pluralsight, I decided to start trying some aspects of C++ on very small microcontrollers.  They're physically small (only about 2cm across) and also small in terms of memory (2kB - 4kB of RAM; 16kB - 32kB of Flash).

Two problems were immediately encountered:

  1. nothing with the iostream library works (e.g. cout).
  2. C++17 doesn't work because the CMSIS library uses the register keyword.

The first issue is due to some C++ libraries taking too much memory.  Iostream is one of these.  The second issue is a known one, having been reported the the ARM folks in 2018.  Hopefully NXP will update its IDE to include the next version of CMSIS that will take care of the problem.

In the meantime, I was able to get a Lambda example working on MCUXpresso 11 using the ISO C++14 compiler:

C++ code

C++ example with lambdas on MCUXpresso 11 for an LPC802 microcontroller. It fit! (c/o