cmath compilation error when compiling old C++ code in VS2010

跟風遠走 提交于 2019-11-30 08:56:40

Are you sure it's compiling as C++? Most compilers will compile .C file as C and .cpp files as C++, compiling a C++ file with a C-compiler will probably fail.

Also, that code mixes oldstyle ('c') headers and newstyle ('c++') headers. It should be more like this (I doubt that is the error however).

#include <fstream>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

That's all I can see with what you've given. But most of the time when you get errors in library files of C/C++ itself, it still is code of you that's wrong somewhere, like forgetting the ; after a class statement in a header file.

Its probably NOT compiling as C++ code - as you assume. I am going to ask you to right click on the file in vs2010, click properties, go to 'Configuration Properties - C/C++ - Advanced', and make sure 'Compile As' is set to 'Compile as C++ Code (/TP)'.. If not, change it to that, then recompile.. you may have to recreate your Pre-compiled Headers, but I am going to be this fixes your 'problem' ;)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!