我在使用 Visual Studio 2012 编译包含 cmath 的 C++ 项目时遇到问题,我收到此错误
error C2065: 'M_PI' : undeclared identifier
我试过这个 M_PI works with math.h but not with cmath in Visual Studio但它根本不起作用
我该如何解决这个问题?
编辑
我几周前下载的应用程序源代码不稳定。所以今天我尝试下载更新的源,现在它就像一个魅力
最佳答案
把下面的代码放在一个头文件中,并包含在你需要M_PI的地方
#pragma once
#include <cmath>
#ifndef M_PI
namespace
{
const double M_PI = std::acos(-1.0);
}
#endif
关于c++ - Visual Studio 中的 M_PI 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22502952/