当我尝试编译下一个简单的代码示例时:
echo "#include <cmath>" | g++ -x c++ -c - -m64 -mfpmath=both -std=gnu++11 -o /dev/null
(与-m64
选项一起激活(默认情况下)使用SSE(例如AVX))。
出现以下错误消息:
In file included from <stdin>:1:0:
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../include/c++/4.7.2/cmath:1040:11: error: '::double_t' has not been declared
c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/../../../../include/c++/4.7.2/cmath:1041:11: error: '::float_t' has not been declared
这是一个错误吗?
如果没有 -mfpmath=both
选项,则不会发生错误。
我的解决方法是添加 -D__FLT_EVAL_METHOD__=2
(如果存在 -Werror
,则添加 -Wp,-w
,因为“已重新定义”警告)到g++的选项列表。我认为这是一种肮脏的方式。
最佳答案
此错误是 mingw-w64 主干上的错误提交。我为此写了一份错误报告。谢谢!
关于c++ - g++ (MinGW)、C++11 和 SSE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13883199/