I'm trying to use C++ strings with emWin on an MCB1800 development board and am hitting problems when I attempt to allocate a value to the string.
I've reduced the code to the following:
#include <string> #include "GUI.h" int main (void) { GUI_Init(); GUI_SetBkColor(GUI_RED); GUI_Clear(); //static char buf [400]; // happy //char const *fred = "Hello world"; // happy //std::string s1; // happy std::string s2("Hello world"); // fail while (1) { GUI_Exec(); } }
If I attempt to allocate "Hello world" to s2 the system locks at =SystemInit in the Reset_Handler. If I uncomment one of the other lines the system starts successfully and I see the red screen.
Does anybody know what is causing this and how I can work around it?
Thanks in advance.
Have you configured a heap, so the std::string constructor can allocate the required buffer?
Thanks for your reply.
I have 0x00001000 allocated to the heap and am using the heap allocation routines from one of the C examples to allocate it.
Do I have to do anything different for C++ / std::string ?