fstream 阻止 math.h 工作
可能的重复:
在 VS2010 中编译旧 C++ 代码时出现 cmath 编译错误
对于在 VS2010 中构建良好的 C++ 程序,编译失败Linux
我正在用 C++ 创建一个程序,我需要在其中读取一个文本文件。我已经包含了 fstream 头文件,它允许我打开该文件,但添加了包括,我现在收到无数与 math.h 函数相关的错误。示例:
1>c:\program files\microsoft visual studio 10.0\vc\include\cmath(19): error C2061: syntax error : identifier 'acosf'
1>c:\program files\microsoft visual studio 10.0\vc\include\cmath(19): error C2059: syntax error : ';'
有什么方法可以在不影响 math.h 函数的情况下包含 fstream 的文本文件读取函数?为什么会发生这种冲突?
/编辑/
错误似乎出现在 cmath 标准头文件中。我无权访问任何内容,但为了完整起见,这里是导致错误的代码:(
using _CSTD acosf; using _CSTD asinf;
using _CSTD atanf; using _CSTD atan2f; using _CSTD ceilf;
等等)
Possible Duplicate:
cmath compilation error when compiling old C++ code in VS2010
Compilation fails in VS2010 for C++ programs building fine in Linux
I am creating a program in C++ in which I need to read a text file in. I have included the fstream header file, which allows me to open the file, but having added the include, I now receive countless errors relating to math.h functions. Examples:
1>c:\program files\microsoft visual studio 10.0\vc\include\cmath(19): error C2061: syntax error : identifier 'acosf'
1>c:\program files\microsoft visual studio 10.0\vc\include\cmath(19): error C2059: syntax error : ';'
Is there any way I can include the text file reading functions of fstream without compromising the math.h functions? And why does this conflict occur anyway?
/Edit/
It seems the errors are in the cmath standard header file. It is nothing I have access to, but for the sake of completion, here is the code that is causing the errors:
using _CSTD acosf; using _CSTD asinf;
using _CSTD atanf; using _CSTD atan2f; using _CSTD ceilf;
(etcetera)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编译运行:
math.h 中已经有 acos(double)、acos(float)、acos(long double) 的重载定义,无需使用 acosf。
您的代码某处有错误。
Compiling and running:
There is already overloaded definitions for acos(double), acos(float), acos(long double) at math.h, there is no need to use acosf.
There is an error somewhere at your code.