Great Engine not compiling
When I try to build the great engine from nehe''s site I get the following error
d:\my documents\opengl\greatengine\source\main\cmath.h(88) : fatal error C1001: INTERNAL COMPILER ERROR
this is the line causing the error:
friend CVector3 operator-(const CVector3& lhs, const CVector3& rhs) { return CVector3(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); }
anyone have any idea what''s causing this?
I haven''t tried compiling that, what compiler (I presume VC++ from the message)? what version of that compiler?
If VC++ then is it all service packed up? If not, do it (see the microsoft site for the sp downloads).
If VC++ then is it all service packed up? If not, do it (see the microsoft site for the sp downloads).
VC++ 6. I'm pretty sure I have the latest patches but I'll check to be sure.
[edited by - Jederas on October 2, 2003 1:31:27 PM]
[edited by - Jederas on October 2, 2003 1:31:27 PM]
October 02, 2003 12:38 PM
The line looks like proper c++ code... ??
I''d suggest just re-downloading the file in question if you can. Maybe it''s got some corruption somewhere.
Also, make sure there''s spaces between the "operator-(const" part. You never know.
I''d suggest just re-downloading the file in question if you can. Maybe it''s got some corruption somewhere.
Also, make sure there''s spaces between the "operator-(const" part. You never know.
October 02, 2003 08:22 PM
Hrm... I would taking the CVector3 constructor out of the return statement. I would make it a two line statement
Cvector3 temp(...);
return temp;
Cvector3 temp(...);
return temp;
shouldn''t you exclude the friend statement from the front of the function. You will only need to put
friend CVector3 operator-(const CVector3 &,const Cvector3 &);
inside the CVector3 class and
CVector3 operator-(const CVector3& lhs, const CVector3& rhs) { return CVector3(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); }
outside of the class.
But I don''t know why you would want the x y and z values to be private anyway. Make them public you don''t need to ensure any data consistency or information hiding, its not like your vector internals are going to change much.
friend CVector3 operator-(const CVector3 &,const Cvector3 &);
inside the CVector3 class and
CVector3 operator-(const CVector3& lhs, const CVector3& rhs) { return CVector3(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); }
outside of the class.
But I don''t know why you would want the x y and z values to be private anyway. Make them public you don''t need to ensure any data consistency or information hiding, its not like your vector internals are going to change much.
"Internal Compiler Error".
There is one possibility that comes to mind. VC++ tends to dislike friend functions being defined and declared at the same time.
The prototype of the function leads me to believe it is being declared inside a class. (Specifically, the proceeding friend, which would only make sense inside a class. Otherwise, what is it a friend of?)
The solution is simple. Declare the function as ''friend'' inside the class
and then define it after the class - it can still be in the header file - with what you already have, minus the friend
If this doesn''t work, you might have to break it up some more.
Declare the class : class CVector3;
Protype the function: CVector3 operator-(...);
Define the class, declaring operator-(...) as friend
And finally, in the associated cpp file, define the function.
This is guaranteed to work. I know, because it''s how I ended up doing it. Of course; if you simply make your operators part of the class, you avoid this problem entirely.
There is one possibility that comes to mind. VC++ tends to dislike friend functions being defined and declared at the same time.
The prototype of the function leads me to believe it is being declared inside a class. (Specifically, the proceeding friend, which would only make sense inside a class. Otherwise, what is it a friend of?)
The solution is simple. Declare the function as ''friend'' inside the class
friend CVector3 operator-(const CVector3&, const CVector3&);
and then define it after the class - it can still be in the header file - with what you already have, minus the friend
CVector3 operator-(const CVector3& lhs, const CVector3& rhs) { return CVector3(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z); }
If this doesn''t work, you might have to break it up some more.
Declare the class : class CVector3;
Protype the function: CVector3 operator-(...);
Define the class, declaring operator-(...) as friend
And finally, in the associated cpp file, define the function.
This is guaranteed to work. I know, because it''s how I ended up doing it. Of course; if you simply make your operators part of the class, you avoid this problem entirely.
quote:
Original post by Anonymous Poster
Hrm... I would taking the CVector3 constructor out of the return statement. I would make it a two line statement
Cvector3 temp(...);
return temp;
That''s not the smartest thing. Usualy compiler can better optimize unnamed(temp?) variables. (From effective c++).
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement