【问题标题】:_fpreset error in visual studio 2010Visual Studio 2010 中的 _fpreset 错误
【发布时间】:2013-01-28 19:23:35
【问题描述】:

早安。

我在使用 c++ 的 Visual Studio 2008 解决方案上有以下定义(这个程序是由在我之前在这里工作的人创建的):

[DllImport("msvcr70.dll", CallingConvention = CallingConvention::Cdecl)]
extern int _fpreset();

这条线完美无缺,我可以在代码上调用 _fpreset。

由于我们需要将其实现为 64 位应用程序,因此我安装了 Visual Studio 2010。从存储库下载解决方案后,它要求我进行转换才能正常工作。我单击是,当我尝试编译程序时,出现以下错误:

error C2556:'int _fpreset(void)': overloaded functions only differ by return type with 'void _fpreset(void)'

当我在 Visual Studio 2008 中再次尝试时,它可以完美运行...

任何想法为什么它在 2010 年不起作用?

【问题讨论】:

  • 听起来 _fpreset() 被声明了不止一次。
  • 是的,但是如果我删除该声明,当我使用它时,我会收到以下警告:'_fpreset': Direct floating point control is not supported or reliable from within managed code
  • 嗯,是的。 The documentation 表示“公共语言运行时只支持默认的浮点精度。”

标签: .net visual-studio-2010 visual-c++


【解决方案1】:

声明是错误的。你现在被提醒了,因为你 #include 引入了 float.h 的其他一些 VS2010 .h 文件,它是声明 _fpreset() 的头文件。这给出了这个 CRT 函数的正确声明,返回类型为 void

您应该删除这个 [DllImport] 声明,不仅因为它是错误的,而且它还使您的程序依赖于古老的 VS2002 CRT (msvcr70.dll)。将此添加到实际调用 _fpreset() 的任何源代码文件中:

 #include <float.h>

在托管代码中调用 _fpreset() 非常有问题,只有在调用会弄乱 FPU 控制字的本机代码时才这样做。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-06
    • 1970-01-01
    • 2011-02-28
    • 1970-01-01
    • 2015-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多