I'm trying to make an SDL game for Mac using C++. I've got everything SDL-related working fine, but when I try and use the sqrt function I get the error no matching function for call to 'sqrt'
. Here's my list of includes and my first function (the main() function doesn't really do anything right now):
#include <iostream>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <math.h>
#include "geometry.h"
using namespace std;
void drawLine(vector2 start, vector2 end)
{
double x = end.x - start.x;
double y = end.y - start.y;
double length = sqrt(x*x, y*y); // I get the error here
}
I've also tried importing with the same results. Is there anything special I have to do on Mac (Lion, XCode 4.3) to get this working?
EDIT: for completeness, geometry.h contains the definition for the vector2 struct
sqrt
only takes one argument. You are giving it two. Perhaps you meant to do this:
double length = sqrt(x*x + y*y);
Or did you confuse sqrt with hypot?