visual-studio ms vc++ iostream 编译错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3376224/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ms vc++ iostream compile error
提问by brian
The following code in microsoft visual C++ 2010 express:
microsoft visual C++ 2010 express 中的以下代码:
#include <iostream>
//using namespace std;
int main(int argc, char **argv)
{
return(0);
}
gives me the errors:
给我的错误:
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(41): fatal error C1003: error count exceeds 100; stopping compilation ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If comment out “#include ” then it compiles. I created an project from existing code and edited to the above.
如果注释掉“#include”然后它编译。我从现有代码创建了一个项目并编辑为上述内容。
回答by Michal Z
Change extension from .cto .cpp
将扩展名更改.c为.cpp
回答by Ko-Barde
Sorry for my bad English.
对不起,我的英语不好。
I'd the same problem an was resolved with this configuration parameter:
我遇到了同样的问题,并使用此配置参数解决了:
- Tools bar -> Project -> Properties (or Alt + F7).
- Configuration Properties -> C/C++ -> Advanced.
- Compile As
- 工具栏 -> 项目 -> 属性(或 Alt + F7)。
- 配置属性 -> C/C++ -> 高级。
- 编译为
If you have in "Compile As" field the value "Compile as C Code" then you must change it to Default or "Compile as C++ Code".
如果您在“编译为”字段中有值“编译为 C 代码”,那么您必须将其更改为默认值或“编译为 C++ 代码”。
I hope I have been helpful
我希望我有所帮助
Best regards
最好的祝福
回答by C Johnson
I don't have the express edition installed, but I bet it's because you have commented out the using namespace std;snippet.
我没有安装 express 版本,但我敢打赌这是因为您已经注释掉了using namespace std;代码段。
Though your code sample compiles just fine in VS 2008 prof edition.
尽管您的代码示例在 VS 2008 专业版中编译得很好。

