6 years, 8 months ago.

C++ iostream lib issues

Hi there,

I encounter a compiler error which was once no problem months ago. My code is as follows:

A random blinky test program

//NXP LPC1114
#include "mbed.h"
#include <cstdlib>
#include <iostream>

DigitalOut led(dp14);

int main()
    //using namespace std;
        led = rand() % 2;
        //led = 1;
        //cout << "Hello World!\n\r" << endl;
        led = 0;

And those compiling error messages are: Error: No space in execution regions with .ANY selector matching ios.o(.bss). Error: Sections of aggregate size 0x1d30 bytes could not fit into .ANY selector(s).

The same code was compiled successfully months ago, but I got those error messages recently. By commenting out the iostream lib, the code is compiled successfully.

By the way, the iostream lib works fine in FRDM-KL25Z and FRDM-KL46Z boards.

Question relating to:

The LPC1114FN28 is an ARM Cortex-M0 based, low-cost 32-bit MCU, designed for 8/16-bit microcontroller applications, offering performance, low power, simple instruction set and memory addressing together with reduced code size …

1 Answer

6 years, 8 months ago.

The optimization settings were changed with the last mbed lib, you can try using one older (I don't get why those optimizers can't optimize for as much speed as possible, but always make sure it fits). The issue now is that it simply doesn't fit. The kL25Z and KL46Z have more memory, so there it fits.

That said, in general it is better not to use IOStream, it uses alot of memory, printf uses way less.

Accepted Answer

Hi Erik,

Thanks again!

I got it, I will use printf in the future.

With kind regards, jppang

posted by JP PANG 16 Feb 2014