[英]Ambiguous overload for 'operator='
我正在嘗試從Festival
項目中編譯一些C++
代碼。 編譯Festival
,出現以下錯誤:
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
發生錯誤的函數:
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();
}
如何擺脫以上錯誤?
get_upto_eoln
返回什么?
您可以在EST_String
類中具有operator=
的確切重載。
或者,您可以顯式地使用它來創建一個字符串,例如:
line = std::string(ts.get_upto_eoln());
代替
line = ts.get_upto_eoln();
我假設您使用的非標准類型來自speech-tools
庫( 在此處記錄) ,因為這是我在搜索類名時發現的。 如果那是錯誤的,請更新問題以指出它們的來源。
我還要假設錯誤行( di_io.cc
111 di_io.cc
)是這樣的:
line = ts.get_upto_eoln();
因為那是我看到的唯一一個可能導致該錯誤消息的代碼; 再次,如果是另一行,請更新問題。
EST_TokenStream::get_upto_eoln
返回EST_Token
。 您正在嘗試將其分配給其他類型的變量( EST_String
),並且沒有隱式轉換。
您可以使用其string
函數將函數結果轉換為EST_String
:
line = ts.get_upto_eoln().string();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.