为何无法使用sqrtl()?

tonny5129 2005-05-05 01:37:10
我首先在“FileView”中的"Header Files"中通过添加文件到目录中加入了MATH.H
然后我的文件如下:
#include <cstdlib>
#include <iostream>
#include <MATH.H>
#include "stdafx.h"

long double lineLength(long double x1,long double y1,long double x2,long double y2)
{
long double temp;
temp = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
temp =sqrtl(temp);
return temp;
}

编译时提示错误:
C:\download\tonny\xin\jisuan.cpp(10) : error C2065: 'sqrtl' : undeclared identifier

搞不懂了,我鼠标移到sqrtl的时候还是可以有提示的,按道理说就是已经定义好了吧,怎么会有这个错误呢
...全文
167 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
surstar 2005-05-05
  • 打赏
  • 举报
回复
你是不是用了 using namespase std;

#include <cstdlib>
#include <iostream>
#include <MATH.H> //
surstar 2005-05-05
  • 打赏
  • 举报
回复
Previous 16-bit versions of Microsoft C/C++ and Microsoft Visual C++ supported the long double, 80-bit precision data type. In Win32 programming, however, the long double data type maps to the double, 64-bit precision data type. The Microsoft run-time library provides long double versions of the math functions only for backward compatibility. The long double function prototypes are identical to the prototypes for their double counterparts, except that the long double data type replaces the double data type. The long double versions of these functions should not be used in new code.

--------------sqrtl() 是LONG DOUBLE 已经不用了, ~
tonny5129 2005-05-05
  • 打赏
  • 举报
回复
老大,改成你那个2还是一样的
temp =sqrt(2);
surstar 2005-05-05
  • 打赏
  • 举报
回复
sqrt() 你写错了吧~
surstar 2005-05-05
  • 打赏
  • 举报
回复
把temp =sqrtl(temp);这句话替换成temp =sqrt(2);错误提示还是一样的
改成
temp =sqrt(2); //你的2和我的2不一样的
surstar 2005-05-05
  • 打赏
  • 举报
回复
The long double versions of these functions should not be used in new code.

如果真如我所说,那么这个函数已经不用了,VC 肯定会报错的!
tonny5129 2005-05-05
  • 打赏
  • 举报
回复
把temp =sqrtl(temp);这句话替换成temp =sqrt(2);错误提示还是一样的
jerry 2005-05-05
  • 打赏
  • 举报
回复
好象确实没有这个函数.我查MSDN都没有
jerry 2005-05-05
  • 打赏
  • 举报
回复
sqrtl 这个函数没有
tonny5129 2005-05-05
  • 打赏
  • 举报
回复
二楼的,应该是有这个函数的,你可以到MATH.H文件中查找

楼上的,也许你说的是个原因,但是这里可能不是这个错,我把temp =sqrtl(temp);这句话替换成temp =sqrtl(2);错误提示还是一样的

16,550

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧