我正在尝试使用 MingW (msys2) 在 Windows 上编译程序,但由于 j0 函数而失败。在Linux上编译没有问题。当我在编译器上使用 -std=c++11 标志时,它似乎很讨厌。如何正确编译并打开 -std=c++11 标志?
示例代码:
#include <cmath>
int main( int argc, char *argv[] )
{
float test = j0( 5 );
}
Output
$ g++ -std=c++11 test.cpp -o test
test.cpp: In function 'int main(int, char**)':
test.cpp:6:21: error: 'j0' was not declared in this scope
float test = j0( 5 );
显然,MinGW 仅在以下情况下定义贝塞尔函数:__STRICT_ANSI__
未定义,并且在以下情况下定义-std=c++11
已指定。我可以通过添加来让你的代码在 MinGW 中编译#undef __STRICT_ANSI__
在文件的顶部。看https://sourceforge.net/p/mingw-w64/feature-requests/68/ https://sourceforge.net/p/mingw-w64/feature-requests/68/
你也可以尝试-std=gnu++11
反而。看https://stackoverflow.com/a/19667112/10077 https://stackoverflow.com/a/19667112/10077
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)