我刚刚使用 mingw-get-setup
更新了 MinGW,如果我在使用 -std=c++1y
以及大于 -O0
的参数时,无法构建任何包含 <cmath>
头文件的东西。(我也尝试过 c++11
和 c++98
)我会得到像这样的错误:
g++.exe -pedantic-errors -pedantic -Wextra -Wall -std=c++1y -O3 -c Z:\Projects\C++\L6\src\events.cpp -o obj\src\events.o
In file included from z:\lander\mingw\lib\gcc\mingw32\4.8.1\include\c++\cmath:44:0,
from Z:\Projects\C++\L6\src\utils.h:4,
from Z:\Projects\C++\L6\src\events.cpp:10:
z:\lander\mingw\include\math.h: In function 'float hypotf(float, float)':
z:\lander\mingw\include\math.h:635:30: error: '_hypot' was not declared in this scope
{ return (float)(_hypot (x, y)); }
我的电脑出了问题吗?
还是mingw仓库的版本有bug?如果是这样,是否有快速修复此头文件的方法?
#include <cmath>
的程序中,还是只有调用hypot()
函数的程序中才会出现? - Keith Thompson#include <cmath>
的程序。 - HolyBlackCat-lm
是多余的;libm.a
实际上是一个空档案,数学功能由默认的C运行时库提供(可以是Microsoft的MSVCRT.DLL本身,也可以是MinGW.org的libmingwex.a扩展库,两者都是默认搜索的)。 - Keith Marshall