Strange compilation errors with mingw

Recommended Posts

I've recently been getting too many INTERNAL COMPILER ERRORs with VC++ for my patience and so decided to try to switch to using mingw instead of the compiler that comes with VC++ (tried this before... but I finally found a descent alternative IDE as well). The problem that I get compiling my sources seems quite strange, I have the function:
inline v2 norm()
{
float l = length();
>>>	return v2(x/l,y/l);

}


The line with the carrots (>>>) generates the error: error: no matching function for call to 'v2::v2(v2)' I have the constructors:
	inline v2(float ix,float iy){x=ix;y=iy;}
inline v2(float *v){memcpy(&x,v,sizeof(float)*2);}
inline v2(v2 &o){x=o.x;y=o.y;}


And this sort of thing always compiled with VC++ (of course it's not exactly standards compliant), so could someone point out my stupid mistake here? I've tried playing around with it for a while to no avail, and all help is greatly appreciated, ~SPH

Share on other sites
Maybe not answering your real question: about the Internal compiler errors: are you compiling source that you have one a network drive? Visual C++ seems unable to handle that, copy it to a local drive and your fine..

Share on other sites
I think the gcc compiler wants a constructor of the form:
inline v2(const v2& o) { ... }

Share on other sites
you want:
inline v2(const v2 &o){x=o.x;y=o.y;}

edit: beaten by 30seconds :p

Share on other sites
Your copy constructor should take a reference-to-const:
inline v2(v2 const & o);

Enigma

Share on other sites
>> Message put in its own thread <<<

[Edited by - ShmeeBegek on June 23, 2005 11:41:42 AM]

Share on other sites
typename list<Character*>::iterator it;

iterator is a dependent name and therefore requires the typename keyword to disambiguate it.

Enigma

Create an account

Register a new account

• Forum Statistics

• Total Topics
627737
• Total Posts
2978880

• 10
• 10
• 21
• 14
• 13