此问题与此主题相关:cygwin support for C++11 in g++4.9.2
我有同样的问题:
error: ‘log2’ is not a member of ‘std’
我应用了建议的补丁,只是为了得到另一个错误。 包括cmath在这里
#include <cmath>
#include <iostream>
int main()
{
std::cout << "hello" << std::endl;
}
返回此错误
$ g++ -std=c++11 test.cpp
In file included from test.cpp:1:0:
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cmath:1107:11: error: '::lrintl' has not been declared
using ::lrintl;
^
/usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cmath:1129:11: error: '::rintl' has not been declared
using ::rintl;
我在cygwin IRC频道上寻求帮助:
[23:02] <XXX> hi, has anyone had problems with gcc 4.9.2 in cygwin? i encountered the problem discussed here : https://cygwin.com/ml/cygwin/2015-03/msg00247.html
[23:03] <XXX> yet, if i apply the patch, i get another error: /usr/lib/gcc/x86_64-pc-cygwin/4.9.2/include/c++/cmath:1107:11: error: '::lrintl' has not been declared
[23:28] <YYY> long double functions are still missing on cygwin
[23:30] <XXX> so is there no way to make it work then?
[23:31] <YYY> sure, help add the missing functions to newlib/cygwin
[23:34] <XXX> i am not using any long double functions in my code -- so i assume including cmath does not work for anybody?
[23:35] <YYY> just drop the std:: instead
[23:37] <XXX> sorry, i'm not sure what you mean. remove 'std::' where ?
可悲的是,谈话在那里结束了。我不知道我应该'删除std ::',也不知道是否能解决问题。
任何人都可以帮忙吗?
答案 0 :(得分:0)
如果我这样做,未修补的<cmath>
在这里工作正常:
auto x = log2(10);
而不是:
auto x = std::log2(10);
也许这就是'drop std ::'的YYY意思。
如果您必须使用已修补的<cmath>
,则可以注释掉两个有问题的行,或者如果您不想修改标题,则添加一些虚拟定义{{1在包含它之前和} rintl
。例如:
lrintl