Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ JNA指针到指针_C++_C_Pointers_Java Native Interface_Jna - Fatal编程技术网

C++ JNA指针到指针

C++ JNA指针到指针,c++,c,pointers,java-native-interface,jna,C++,C,Pointers,Java Native Interface,Jna,我试图使用JNA并使用指向指针的指针执行,但我一直遇到问题。我可以在类中使用其他函数,但是这个函数中的参数给我带来了麻烦。我的接口和java在哪里工作良好,我可以使用其他方法,但是“execute_file”和“alenkaexecute”给我带来了麻烦。我的方法声明取消了吗?我在想也许我应该有一个字符串数组而不是指针引用?在底部,我包含了C++和Excel文件。 谢谢大家! public interface libcvm extends Library{ void alenka

我试图使用JNA并使用指向指针的指针执行,但我一直遇到问题。我可以在类中使用其他函数,但是这个函数中的参数给我带来了麻烦。我的接口和java在哪里工作良好,我可以使用其他方法,但是“execute_file”和“alenkaexecute”给我带来了麻烦。我的方法声明取消了吗?我在想也许我应该有一个字符串数组而不是指针引用?在底部,我包含了C++和Excel文件。 谢谢大家!

public interface libcvm extends Library{
        void alenkaInit(PointerByReference av);
        int execute_file(int ac, PointerByReference av);
        void alenkaClose();
        int alenkaExecute(ByteBuffer s); 
    }
        public static void main(String[] args) {
        libcvm libcvm = (libcvm) Native.loadLibrary("libcvm.so", libcvm.class);
        PointerByReference pref = new PointerByReference();
        libcvm.execute_file(2, pref);
        Pointer p = pref.getValue();    
    }


int execute_file(int ac, char **av)
{
bool just_once = 0;
string script;

    process_count = 6200000;
    verbose = 0;
total_buffer_size = 0;

    for (int i = 1; i < ac; i++) {
        if(strcmp(av[i],"-l") == 0) {
            process_count = atoff(av[i+1]);
        }
        else if(strcmp(av[i],"-v") == 0) {
            verbose = 1;
        }
        else if(strcmp(av[i],"-i") == 0) {
            interactive = 1;
break;
        }
        else if(strcmp(av[i],"-s") == 0) {
            just_once = 1;
interactive = 1;
script = av[i+1];
        };  
    };

load_col_data(data_dict, "data.dictionary");

    if (!interactive) {
        if((yyin = fopen(av[ac-1], "r")) == NULL) {
            perror(av[ac-1]);
            exit(1);
        };

        if(yyparse()) {
            printf("SQL scan parse failed\n");
            exit(1);
        };

//exit(0);

        scan_state = 1;
        std::clock_t start1 = std::clock();

load_vars();

        statement_count = 0;
        clean_queues();

        yyin = fopen(av[ac-1], "r");
        PROC_FLUSH_BUF ( yyin );
        statement_count = 0;

        extern FILE *yyin;
        context = CreateCudaDevice(0, av, verbose);
        hash_seed = 100;

        if(!yyparse()) {
            if(verbose)
            cout << "SQL scan parse worked " << endl;
        }
        else
            cout << "SQL scan parse failed" << endl;

        fclose(yyin);
        for (map<string,CudaSet*>::iterator it=varNames.begin() ; it != varNames.end(); ++it ) {
            (*it).second->free();
        };

        if(alloced_sz) {
            cudaFree(alloced_tmp);
        };

        if(verbose) {
            cout<< "cycle time " << ( ( std::clock() - start1 ) / (double)CLOCKS_PER_SEC ) << " " << getFreeMem() << endl;
        };
    }
    else {
        context = CreateCudaDevice(0, av, verbose);
        hash_seed = 100;
if(!just_once)
getline(cin, script);   

        while (script != "exit" && script != "EXIT") {

used_vars.clear();
            yy_scan_string(script.c_str());
            scan_state = 0;
            statement_count = 0;
            clean_queues();
            if(yyparse()) {
                printf("SQL scan parse failed \n");
                getline(cin, script);
                continue;
            };

            scan_state = 1;

load_vars();

            statement_count = 0;
            clean_queues();
            yy_scan_string(script.c_str());
            std::clock_t start1 = std::clock();

            if(!yyparse()) {
                if(verbose)
                    cout << "SQL scan parse worked " << endl;
            };
            for (map<string,CudaSet*>::iterator it=varNames.begin() ; it != varNames.end(); ++it ) {
                (*it).second->free();
            };
            varNames.clear();

            if(verbose) {
                cout<< "cycle time " << ( ( std::clock() - start1 ) / (double)CLOCKS_PER_SEC ) << endl;
            };
if(!just_once)
getline(cin, script);
else
script = "exit";
        };
        if(alloced_sz) {
            cudaFree(alloced_tmp);
            alloced_sz = 0;
        };

while(!buffer_names.empty()) {
delete [] buffers[buffer_names.front()];
buffer_sizes.erase(buffer_names.front());
buffers.erase(buffer_names.front());
buffer_names.pop();
};

    };
if(save_dict)
save_col_data(data_dict,"data.dictionary");
    return 0;
}
公共接口libcvm扩展库{
void alenkaInit(指针参考av);
int execute_文件(int ac,PointerByReference av);
void alenkaClose();
int alenkaExecute(ByteBuffer s);
}
公共静态void main(字符串[]args){
libcvm libcvm=(libcvm)Native.loadLibrary(“libcvm.so”,libcvm.class);
PointerByReference pref=新的PointerByReference();
libcvm.execute_文件(2,pref);
指针p=pref.getValue();
}
int execute_文件(int ac,字符**av)
{
bool just_once=0;
字符串脚本;
过程计数=6200000;
详细=0;
总缓冲区大小=0;
对于(int i=1;icout您的API要求的是
char**
,这在C语言中通常是一个字符串数组

如果使用
String[]
作为参数类型,JNA将自动处理转换