Compiling old code failing at struct command

I am (attempting) compiling something from 2016 and the compiler (Cinder) has changed a bit since then...the code is choking on this...

1
2
3
4
5
  struct Cursor {
    static const int kNoPosition = -100;
    int pos;
    double lastUpdate;
};


With that bit of code in place I get this error...

1
2
3
4
In file included from /home/pi/Cinder/samples/CollidoscopeApp/src/CollidoscopeApp.cpp:31:0:
/home/pi/Cinder/samples/CollidoscopeApp/include/Wave.h:58:16: error: using typedef-name ‘Cursor’ after ‘structtypedef struct Cursor {
                ^


If I comment out the struct call I get...

1
2
3
error: request for member ‘pos’ in ‘cursor’, which is of non-class type ‘Cursor {aka long unsigned int}’
         cursor.pos = pos;
                ^


So it needs something there, but that struct call conflicts with X11 .

https://code.soundsoftware.ac.uk/projects/opencollidoscope/repository/show/CollidoscopeApp

the offending lines are in include/Wave.h

Cinder now uses cmake so I already had to edit the CMakeLists.txt file to even attempt to compile.
Your error shows the word "typedef" in front of "struct", but that's not in the actual code. If you have it there in your copy, remove it.

If the name Cursor is conflicting with something in X11, then change it to Cursor2 (or whatever) everywhere it occurs in the code.
I changed so many things...I must have pasted the wrong error...

1
2
3
4
from /home/pi/Cinder/samples/CollidoscopeApp/src/CollidoscopeApp.cpp:24:
/usr/include/X11/X.h:103:13: note: ‘Cursor’ has a previous declaration here
 typedef XID Cursor;
             ^


I tried renaming Cursor and got these errors...

1
2
3
4
5
6
7
/home/pi/Cinder/samples/CollidoscopeApp/src/Wave.cpp: In member function ‘void Wave::update(double, const DrawInfo&)’:
/home/pi/Cinder/samples/CollidoscopeApp/src/Wave.cpp:79:38: error: conversion from ‘std::map<int, CCursor>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, CCursor> >}’ to non-scalar type ‘MapItr {aka std::_Rb_tree_iterator<std::pair<const int, long unsigned int> >}’ requested
     for (MapItr itr = mCursors.begin(); itr != mCursors.end(); ++itr){
                                      ^
/home/pi/Cinder/samples/CollidoscopeApp/src/Wave.cpp:79:45: error: no match foroperator!=’ (operand types are ‘MapItr {aka std::_Rb_tree_iterator<std::pair<const int, long unsigned int> >}’ and ‘std::map<int, CCursor>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, CCursor> >}’)
     for (MapItr itr = mCursors.begin(); itr != mCursors.end(); ++itr){
                                             ^
(and another 1000 lines of errors)

So I wasn't sure if it was a wrong use of the X11 Cursor, or if they were trying to define a new item...I couldn't tell if I was making things worse.
Followup...

You shouldn't attempt to code when tired.

I mentioned that I had renamed the 'Cursor' in the Wave.h file...however I failed to also rename 'Cursor' in the Wave.cpp file...that created the 1000 lines of errors.

Once I renamed Cursor in both files it compiled without error.


So thanks for the help!

...it is hard to enter someone else's code and fix...

Mike
Topic archived. No new replies allowed.