2015-06-09 26 views
1

嗨我收到一個錯誤「__result未在此範圍內聲明」。沒有可變的「結果」了。 「outResult」之前被命名爲「結果」。但改名了。__result未在此範圍內聲明

我確實減少了代碼。這是沒有道理的,但現在很簡單,我得到的錯誤。

是否有我可以刪除的臨時文件?

在此先感謝

#include <Rcpp.h> 
using namespace Rcpp; 

// Rf_warning 
// [[Rcpp::export]] 

// Function findPIPs_cpp 
NumericVector findPIPs_cpp(NumericVector x, NumericVector y) { 

    IntegerVector PIPs(x.size()); 
    IntegerVector outResult(x.size()); 
    NumericVector PIPLine(x.size()); // Interpolated Values 


    outResult[0] = 0; 
    outResult[1] = y.size()-1; 

    int i = 0; 
    int n = 1; 

    // sort the existing PIPs 
    PIPs = outResult[outResult > 0]; 
    std::sort(PIPs.begin(), PIPs.end()); 

    // first point of the interpolated line 
    PIPLine[0] = y[PIPs[0]]; 


    PIPLine[n] = margin * (x[PIPs[i]]-x[PIPs[i+1]]) + y[PIPs[i]]; 



    return PIPLine; 


} 
+1

如果您檢查Rcpp-Attributes vignette中的文檔,就會發現您只是簡單地使用了'sourceCpp()'錯誤的方法。 –

回答

1

圖克我一些時間才能體現出來。 這是

// [[Rcpp::export]] 

和該問題的函數名稱之間的行。刪除評論後,它運行

// Function findPIPs_cpp 

所以對於別人 - 不要在那裏評論。 仍然會很好,知道爲什麼。 ;)

感謝和問候。

+1

至於爲什麼--Rcpp屬性解析器期望函數定義緊跟在註釋之後;之後的其他評論並不足夠「聰明」。 –