ARM GCC compiler std::vector

Hi Everybody:
so I was making some test with std::vector with codeblocks and the try to test same code on hardware with embitz.
The problem here is in this segment of code:

void World::update()
{
    auto e = std::begin(entities);
    while (e != std::end(entities))
    {
        //Update
        (*e)->Update();

        //Remove if dead
        if ((*e)->Life<1)
        {
            delete(*e);
            e = entities.erase(e);
        }
        else
        {
            ++e;
        }
    }
}

Where entities is a vector of pointers to a base class GameObj

vector<GameObj*> entities;

Code works as expected in Code::Blokcs iterating trough all the entities and removing them when aged.
In Embtiz it seems like the auto keyword broke the compiler:

Is something not supported by ARM GCC?
Thanks for help.

Seems that C++11 is listed as a compiler option but isn’t enabled by default for the Pokitto library project:

I haven’t tested if a Pokitto program compiled with C++11 enabled still runs alright on the Pokitto, but it certainly compiles.

1 Like

Great @Pharap it works! I was sure you’d be the one with the right answer about c++
Thanks again.

If C++11 is supported by arm gcc, why that option was not checked @jonne?

2 Likes

C++11 is fully supported in EmBitz toolchain.

Unfortunately mbed online compiler does not support C++11. I think I turned it off at some point, but for working offline I guess it should be enabled by default.

2 Likes

Legend has it that if you say C++11 three times I appear in the mirror.

4 Likes

That’s a good new for me. C++ features are very comfortable. Also it allow to have same code for Code::Blocks and Embitz.

I keep waiting more tutorials in the subject :wink:

1 Like

@Pharap

YES! Public demands C++11 lessons from ground up!

1 Like

I hope to get chance to, as well as finishing those PEX tutorials (I haven’t completely forgotten them).

The last few months most of my spare time has been preoccupied with another project I’ve been helping with, which was finally released on 2017/12/20 after about 2-3 months of work, and then had a few major updates in the following weeks (even on Christmas day the two programmers, myself and filmote (Simon Holmes), were discussing space-saving updates).

I’ve been having a (somewhat deserved) break since then, focusing more on playing games than writing them, lest my brain start melting.

Out of interest, if I were to write a document/article explaining C++11 features to people familiar with C++03/C++ in general, would there be any interest in that?

(Or were you thinking more of a “C++ with no prior experience, from a C++11 point of view” type of thing?)

3 Likes

I’ve some experience with other languages, as the most of us I suppose (Lua, Basic, Python, C# etc).
Basic tutorial (if-then-else, while, etc) are fine but mostly to point out the difference in using limited resources in embedded system. Otherwise any standard online tutorial is good enough.

I’ve choose Pokitto to learn C/C++ for embedded system. I’ve read some C/C++ tutorials and now I’m looing for the best way to use std library (vector, map etc) and C++11 style (auto etc).
This together a general overview of the API (Modules, Libraries, Graphics, Sound) should give all the tools to develop best app for Pokitto.

1 Like