edapx
April 2, 2019, 7:32am
#1
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?
seb_ly
April 2, 2019, 8:24am
#2
Maybe a non-standard space character sneaked in there? Or some weirdness with the line feed format?
edapx
April 2, 2019, 9:16am
#3
Nope, even removing the whitespace did not fix the issue:
Mousepicker.h:15:19: error: expected unqualified-id before '=' token
float near=0.0f;
^
seb_ly
April 2, 2019, 9:29am
#4
can you link to the file?
edapx
April 2, 2019, 9:30am
#5
Now I am trying to initialize the parameters in the constructor.
#pragma once
#include "ofMain.h"
#include "Ray.h"
namespace ofxraycaster {
class Mousepicker {
public:
Mousepicker(){
near=0.0f;
far=0.0f;
};
void setFromCamera(const glm::vec2& coords, const ofCamera& camera);
void draw(const float radius = 20.0f);
Ray& getRay();
private:
Ray ray;
float near;
float far;
};
This file has been truncated. show original
I do not have a windows machine at the moment, I will wait for appveyor.
edapx
April 2, 2019, 10:12am
#6
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;
^
arturo
April 2, 2019, 10:17am
#8
but you might be missing a semicolon somewhere, probably in an include or something
edapx
April 2, 2019, 10:27am
#9
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?
seb_ly
April 2, 2019, 10:41am
#10
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?
edapx
April 2, 2019, 11:45am
#11
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.
seb_ly
April 2, 2019, 1:26pm
#12
I’ll fire up my windows instance and see if I can find anything.
seb_ly
April 2, 2019, 1:41pm
#13
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.
edapx
April 2, 2019, 2:04pm
#14
That was @seb_ly , thanks for your help