2012-02-06 508 views
1

不明確的過載我想從Festival項目編譯一些C++代碼。當我編譯Festival,我得到以下錯誤:'運營商='

static void load_index(DIPHONE_DATABASE *database) 
{ 
    EST_TokenStream ts; 
    int i; 
    EST_String line; 

    if (ts.open(database->index_file) == -1) 
    { 
    cerr << "Diphone: Can't open file " << database->index_file << endl; 
    festival_error(); 
    } 

    for (i=0; (!ts.eof()) && (i<database->ndiphs);) 
    { 
    line = ts.get_upto_eoln(); //this is di_io.cc:111 
    if ((line.length() > 0) && (line[0] != ';')) 
    { 
     EST_TokenStream ls; 
     ls.open_string(line); 
     database->indx[i]->diph = wstrdup(ls.get().string()); 
     database->indx[i]->file = wstrdup(ls.get().string()); 
     database->indx[i]->beg = atof(ls.get().string()); 
     database->indx[i]->mid = atof(ls.get().string()); 
     database->indx[i]->end = atof(ls.get().string()); 
     ls.close(); 
     i++; 
    } 
    } 

    if (i == database->ndiphs) 
    { 
    cerr << "Diphone: too many diphones in DB" << endl; 
    festival_error(); 
    } 

    database->nindex = i; 
    database->ndiphs = i; 

    ts.close(); 
} 

如何才能擺脫上述錯誤的:

Making in directory ./src ... 
Making in directory src/arch ... 
Making in directory src/arch/festival ... 
Making in directory src/modules ... 
Making in directory src/modules/rxp ... 
Making in directory src/modules/clunits ... 
Making in directory src/modules/clustergen ... 
Making in directory src/modules/MultiSyn ... 
Making in directory src/modules/MultiSyn/inst_tmpl ... 
Making in directory src/modules/hts_engine ... 
Making in directory src/modules/diphone ... 
gcc -c -g -I../include -I../../../src/include -I../../../../speech_tools/include di_io.cc 
di_io.cc: In function ‘void load_index(DIPHONE_DATABASE*)’: 
di_io.cc:111: error: ambiguous overload for ‘operator=’ in ‘line = EST_TokenStream::get_upto_eoln()()’ 
../../../../speech_tools/include/EST_String.h:477: note: candidates are: EST_String& EST_String::operator=(const char*) <near match> 
../../../../speech_tools/include/EST_String.h:479: note:     EST_String& EST_String::operator=(char) <near match> 
../../../../speech_tools/include/EST_String.h:481: note:     EST_String& EST_String::operator=(const EST_String&) <near match> 
make[3]: *** [di_io.o] Error 1 
make[2]: *** [diphone] Error 2 
make[1]: *** [modules] Error 2 
make: *** [src] Error 2 

發生錯誤的功能?

+0

這是行'di_io.cc:111'? – sbi 2012-02-06 10:48:27

+1

我在猜測它的'line = ts.get_upto_eoln();' – Chip 2012-02-06 10:56:03

+0

@Chip:我也這麼認爲,但是猜測是愚蠢的。 – sbi 2012-02-06 11:26:54

回答

2

我假設你使用非標準的類型是從speech-tools庫,記錄在here,因爲這是我在搜索類名時發現的。如果這是錯誤的,請更新問題以表明它們來自哪裏。

我還假設錯誤行(行di_io.cc 111)是一個說:

line = ts.get_upto_eoln(); 

,因爲這是唯一一個我可以看到,可能會導致該錯誤消息;再次,如果它是不同的行,請更新問題。

EST_TokenStream::get_upto_eoln返回EST_Token。您正嘗試將其分配給不同類型的變量(EST_String),並且沒有隱式轉換。

可以使用其string功能轉換功能結果EST_String

line = ts.get_upto_eoln().string(); 
+0

對於我在問題中忽略的所有內容,我表示歉意。我想我的鼻子太靠近地面了。這個答案在解決問題方面是一個很好的教訓。謝謝! – Sriram 2012-02-06 12:00:11

2

get_upto_eoln返回什麼?

您可以在EST_String類中獲得operator=的精確過載。

或者,你可以明確地使一個字符串,它像:

line = std::string(ts.get_upto_eoln()); 

而不是

line = ts.get_upto_eoln(); 
+0

謝謝你的回覆。 – Sriram 2012-02-06 12:00:47