Appveyor complaining

Hello, I have an addon failing on windows with this error:

error: expected unqualified-id before '=' token
         float far = 0.0f;
                   ^

The addon builds on mac and linux, and this is the class causing the error:

    class Mousepicker {
    public:
        Mousepicker(){};
        void setFromCamera(const glm::vec2 coords, const ofCamera camera);
        void draw(const float radius = 20.0f);
        Ray& getRay();

    private:
        Ray ray;
        float near = 0.0f;
        float far = 0.0f;
    };

It seems that windows does not like the initialization of the floats near and far. Any hint?

Maybe a non-standard space character sneaked in there? Or some weirdness with the line feed format?

Nope, even removing the whitespace did not fix the issue:

Mousepicker.h:15:19: error: expected unqualified-id before '=' token
         float near=0.0f;
                   ^

can you link to the file?

Now I am trying to initialize the parameters in the constructor.

I do not have a windows machine at the moment, I will wait for appveyor.

And initializing the variables into the constructor leads to another kind of error:

C:/projects/openFrameworks/addons/ofxRaycaster/src/Mousepicker.h:18:9: error: declaration does not declare anything [-fpermissive]
         float near;
         ^~~~~
C:/projects/openFrameworks/addons/ofxRaycaster/src/Mousepicker.h:19:9: error: declaration does not declare anything [-fpermissive]
         float far;
         ^~~~~
C:/projects/openFrameworks/addons/ofxRaycaster/src/Mousepicker.h: In constructor 'ofxraycaster::Mousepicker::Mousepicker()':
C:/projects/openFrameworks/addons/ofxRaycaster/src/Mousepicker.h:9:17: error: expected primary-expression before '=' token
             near=0.0f;
                 ^
C:/projects/openFrameworks/addons/ofxRaycaster/src/Mousepicker.h:10:16: error: expected primary-expression before '=' token
             far=0.0f;
                ^
float far{0.0f};

should work

but you might be missing a semicolon somewhere, probably in an include or something

It still does not work:

C:/projects/openFrameworks/addons/ofxRaycaster/src/Mousepicker.h:16:18: error: expected unqualified-id before '{' token
         float far{0.0f};

“but you might be missing a semicolon somewhere, probably in an include or something”.

You mean, in one of the included files, right?

I’m pretty sure that when this happened to me it ended up being a weird character in the file somewhere. Try deleting and rewriting the line, rather than copy/paste?

I do not know where to look anymore. I have removed some whitespace and added a missing semicolon in an header file. It still keep failing. The addon consists of just 4 classes, there is not much that can go wrong.

I’ll fire up my windows instance and see if I can find anything.

OK I’ve found the issue - near and far are compiler directives on windows in minwindef.h - change the variable names and the code compiles.

That was @seb_ly, thanks for your help :wink:

Glad I could help! :smiley: