在XCode 4.3中调用'sqrt'没有匹配函数

ben*_*wad 0 c++ macos standard-library xcode4

我正在尝试使用C++为Mac制作SDL游戏.我已经完成了与SDL相关的所有工作,但是当我尝试使用sqrt函数时,我得到了错误no matching function for call to 'sqrt'.这是我的包含列表和我的第一个函数(main()函数现在没有真正做任何事情):

#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
}
Run Code Online (Sandbox Code Playgroud)

我也试过导入相同的结果.有什么特别的我必须在Mac(Lion,XCode 4.3)上做这个工作吗?

编辑:为了完整性,geometry.h包含vector2结构的定义

Ben*_*ley 6

sqrt只需要一个参数.你给它两个.也许你打算这样做:

double length = sqrt(x*x + y*y);
Run Code Online (Sandbox Code Playgroud)

或者你把sqrt与hypot混淆了吗?