2015-04-22 136 views
0

這一問題與此主題:cygwin support for C++11 in g++4.9.2Cygwin的gcc.4.9.2:錯誤: ':: lrintl' 尚未聲明

我有同樣的問題:

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

未打補丁的<cmath>工作正常,在這裏,如果我做的:的

auto x = log2(10); 

代替:

auto x = std::log2(10); 

也許這就是YYY是指「下降STD ::」。

如果必須使用修補<cmath>,您可以註釋掉兩行違規,或者如果你不想修改頭的任何比你已經有了,加rintllrintl一些虛擬的定義,你包括前它。例如:

#include <stdexcept> 
long double rintl(long double arg) { throw std::runtime_error("rintl not implemented"); } 
long lrintl(long double arg) { throw std::runtime_error("lrintl not implemented"); } 

#include <cmath>