gpt4 book ai didi

c++ - Visual Studio 中的 M_PI 问题

转载 作者:太空狗 更新时间:2023-10-29 23:16:40 24 4
gpt4 key购买 nike

我在使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com