Hi, I'm not new to embedded or NXP development but am very new to Eclipse and MCUXpresso. I have a MIMXRT1020-EVK development board.
I'm trying to get some simple C++ code running on it and have a problem with std::map.
Here is a minimal version of my code:
#include <iostream>
#include <list>
#include <map>
int main()
{
// list test
std::list<int> myList;
myList.push_back(33);
std::cout << "list:" << myList.front() << std::endl;
// map test
std::map<int,int> myMap;
myMap[3] = 3;
std::cout << "map:" << myMap[3] << std::endl;
}The output I get is
list:33
map:0
Obviously the map should be giving me 3 instead of 0.
I have tried many things but it's all so new to me I don't know my way around the IDE yet.
I've tried
- Different language standards, currently ISO C++14
- Different libraries, currently Newlib (Auto)
- Using map::at() which throws an exception
- Inserting 3,3 as a std::pair
- Initialising the map with {{3,3}}
- Iterating over the map
- Fairly random trying settings
I've tried std::set as I know that is based on a RedBlack tree too and that also failed. With two entries it iterated only over one of them. If I read the size() it says 2.
Can anyone advise me what I'm doing wrong or what area I should look in? I could understand if none of the STL worked but for list to work and map not really baffles me.
Many thanks
Ant