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?
The problem was because of improper order of functions. I mean I I need to define the signature of all functions before calling them.