I have two structures one is basic, position_3d. The other one is ray.
typedef struct{
float x,y,z;
} position_3d;
typedef struct{
vector_3d direction;
position_3d startPosition;
} ray;
I have implemented a function which return a position_3d struct
position_3d getIntersectionPosition(ray r, sphere s){
position_3d pos;
//some code
pos.x = r.startPosition.x + t*r.direction.x;
pos.y = r.startPosition.y + t*r.direction.y;
pos.z = r.startPosition.z + t*r.direction.z;
return pos;
}
when I call
position_3d pos = getIntersectionPosition(r, s);
I got this error invalid initializer. I am using gcc. The compilation command is gcc prog.c -o prog.out -lm -lGL -lGLU -lglut
I am really stuck now! May anybody help?
Is the line
position_3d pos = getIntersectionPosition(r, s);
at file scope (then that's an error because the initializer is not constant) or block scope (then it should work)?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With