Curious Compiler Issue?

Member
Posts: 321
Joined: 2004.10
Post: #1
Code:
GLVector4        Get_xDir()
{
    // original code
    //return GLVector4(1-2*(y*y+z*z),  2*(x*y+w*z),  2*(x*z-w*y));

    // xcode acceptable code
    GLVector4 v4(1-2*(y*y+z*z),  2*(x*y+w*z),  2*(x*z-w*y));
    return(v4);
}


This was some code off the internet (Linux and Windows) and that I tried
compiling but the errors:
no matching function for call to "GLVector4::GLVector4(GLVector4);
candidates are : GLVector4::GLVector4(GLVector4&);


After much head banking I got it to work by splitting up line as shown above.

Note: I tried
return ( GLVector4(1-2*(y*y+z*z), 2*(x*y+w*z), 2*(x*z-w*y)) );
but this didn't work either.

Could this be an error in Xcode (i.e. gcc ) comipler?




Edit: Just came across this. Must be in the same vein as the above.

Had to change this:
distance = distance2Points(GLVector3(particlePos.x, particlePos.y, particlePos.z),
GLVector3(m_forcesPos[i].x, m_forcesPos[i].y, m_forcesPos[i].z));

to this:

GLVector3 v3(particlePos.x, particlePos.y, particlePos.z);
GLVector3 v3_1(m_forcesPos[i].x, m_forcesPos[i].y, m_forcesPos[i].z);
distance = distance2Points(v3, v3_1);
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Your copy constructor should take a const GLVector4&, not a GLVector4&.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Weird Compiler WARNING... help? Elphaba 1 2,301 Aug 10, 2009 10:51 PM
Last Post: Elphaba
  compiler (pre-processing?) error of SDL project WhatMeWorry 2 2,992 Oct 14, 2005 09:09 PM
Last Post: WhatMeWorry
  weird compiler warnings/errors in Xcode 2.0 Andrew 15 6,763 May 13, 2005 01:07 AM
Last Post: Andrew