Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12595 Discussions

C++ STL types on NIOS - Do they work?

Honored Contributor II

Hi guys, 


I'm having trouble using C++ Standard Template Library types like vector, map and streams in my NIOSII system. 


For reference, my project is a networking application using uCOS-II and NicheStack with c++ enabled. The code is based on a modified Simple Socket Server project. 


There are a number of problems at runtime when testing the code, for example: 


- iterators don't seem to work. looping through a std::vector with an iterator returns garbage and never terminates, but manually looping using vector::size() and vector::at() appears to work. 

- possibly related to the previous point, calling find() on a std::map never terminates 

- streaming classes don't seem to work, for example, the following blows up the system: 


basic_stringbuf<alt_u8> buffer(ios_base::out | ios_base::binary); basic_ostream<alt_u8> out(&buffer); out << 123;  


By 'blow up', I mean stepping over the line in the debugger never completes. After waiting a while and hitting 'pause' in the debugger the code is sitting in ALT_EXIT. Stack trace shows an exception is thrown in basic_ios::clear. But adding try/catch does not let me catch it. 



Any ideas what might be causing this insanity? If I had to guess I would think there must be something funny going on with memory or threading due to uCOS... but I have no idea what! 


Please help! : )
0 Kudos
1 Reply
Honored Contributor II

Such randomness might be caused by running out of stack.

0 Kudos