相关疑难解决方法(0)

在Python中使用回调时出错

我正在开发一个应该在Python中使用的DLL.我有一个回调函数来发送我的参数(在一个单独的标题中定义):

typedef int(*call_nBest)(char **OutList, float* confList, int nB);

所以,我以这种方式使用这个回调:

#define TEXT_BUFFER_MAX_SIZE 50
call_nBest nBestList;
void Xfunction(const char* aLineThatWillBeConvertedInAList){
    char **results;
    float *confidences;
    confidences=new float[nBest];
    results=new char*[nBest];
    for(int i=0; i<nBest; i++) results[i]=new char[TEXT_BUFFER_MAX_SIZE];

    MakeLine2List(aLineThatWillBeConvertedInAList,results,confidences); 

    /*At this function I am having the error :(*/
    nBestList(results,confidences,nBest); // Passing the values to my callback

    for(int i=0; i<nBest; i++) delete [] results[i];
    delete [] confidences;
    delete [] results;

}
Run Code Online (Sandbox Code Playgroud)

我以这种方式导出它:

__declspec(dllexport) int ResultCallback(call_nBest theList){
    nBestList = theList;
    return(0);
}
Run Code Online (Sandbox Code Playgroud)

我以这种方式首先在另一个C++应用程序中测试了我的回调:

int MyCallback(char **OutLi, float* confLi, …
Run Code Online (Sandbox Code Playgroud)

c++ python error-handling callback char

10
推荐指数
1
解决办法
964
查看次数

标签 统计

c++ ×1

callback ×1

char ×1

error-handling ×1

python ×1