OfxSequencer error: 'r' does not name a type

Hi folks, I am very new to OpenFrameworks, so please pardon my noobish questions.

I am currently trying to use the OfxAbletonLive addon, and in the 3rd example it requires the OfxSequencer addon, which I have downloaded and added to my project. When I try to compile my project, the ofxSequencer.cpp seems to be giving me issues regarding the declaration of ‘r’.

At first ‘r’ is declared as an integer

void ofxSequencer::randomize() 
    for (int r=0; r<rows.size(); r++) {

But later on when declared as auto, it gives me an error:

void ofxSequencer::advance()
    column = (column + 1) % cols;
    if (smooth) {
        bpmTime = ofGetElapsedTimeMillis();
        cursor = column;
        for (auto r : rows) {
        for (auto r : rows) {
    ofNotifyEvent(beatEvent, column, this);

I get this error upon compiling:

|error: 'r' does not name a type|

Are there any additional things I have to do to get this addon running? It does not seem to be an issue with the example code, since this is a compiling error directly from ofxSequencer.cpp.

Any help would be much appreciated, thanks!

What version of openFrameworks are you using, and what operating system are you on?

well theres a few things that need to be clarified here. The r in your first snippet of code does not scope outside of that expression so you are not converting types. The r only exists for that for loop, similar to the ones below only things work slightly different with auto.

The rows in the first for loop is a pointer so the notation -> is accessing its member functions through the pointer. I have the feeling that the auto is stripping the pointer in the expression (auto r : rows) which in plain english means for each row in rows where r is each object in the array, and auto means it lets the compiler/runtime pick the object type.

If you change it to r.update(cursor) and r.update(column) do the errors go away? This may not be the case but I am curious if that is whats happening.

You may want to quickly look over these resources

I am currently using the latest (0.8.4) version of OF, running on Windows 7.

I’m wondering if the auto keyword and range_for loops are not working correctly with 0.8.4. It isn’t officially supported until 0.9.0+ w/ C++11. Perhaps try replacing that auto range for loop with a normal for loop like the one in your first section.

Thanks for the clarification. Then I am guessing that the problem lies with the (auto r : row) expression alone. Changing the expression yields the same compilation error.

Just curious, would the auto declaration still work when no prior declarations are being made? How does the process of letting the compiler pick object type work?

Thank you for your quick response!

I think it might have to do with the version as well. I tried changing the declaration to int r like the earlier loop, and it gives me this error:

|error: range-based 'for' loops are not allowed in C++98 mode|

So I am guessing this is a version compatibility issue? I will download 0.9.0+ and try again!

Thanks for your help!

Like @bakercp mentioned above the auto is actually a feature of C++11 so it might not be properly implemented unless you are using the newest version of OF, we have a release candidate up though I would just switch the auto for loop to look exactly like the working loop in the first part of the code, like Chris also mentioned.

Since changing the expression doesn’t change anything I am guessing you are still using an older version of OF but for future reference the auto actually is just part of the expression.
Auto just determines the variable from its initializer and the work of the for loop is actually done by the range_for loop.

When I change the syntax of the loops to a similar expression as the loop in the beginning, I no longer get compilation errors, although the program doesn’t run. I’ll try again with a newer version of OF. I believe that should solve the problem.

Thanks for your help!