使用_beginthread在其他C文件中启动函数

时间:2018-08-03 08:12:15

标签: c++ c multithreading visual-studio

我想在链接到我的文件的其他c文件的线程中运行一个函数,但是遇到错误! ide:Visual Studio 2015 请帮助我。

power.cu文件包含一些内容

#include <process.h>    

之后,在power.cu文件的开头:

extern "C"
void setup();

和power.cu文件中的_beginthread函数:

_beginthread(setup, 0, NULL);

和kmeans.c文件中:

void setup() {
int argc;
int argv;
    int     opt;
extern char   *optarg;
    char   *filename = 0;
    float  *buf;
    char    line[1024];
    int     isBinaryFile = 0;

    float   threshold = 0.001;      /* default value */
    int     max_nclusters=5;        /* default value */
    int     min_nclusters=5;        /* default value */
    int     best_nclusters = 0;
    int     nfeatures = 0;
    int     npoints = 0;
    float   len;

    float **features;
    float **cluster_centres=NULL;
    int     i, j, index;
    int     nloops = 1;             /* default value */

    int     isRMSE = 0;     
    float   rmse;

    int     isOutput = 0;
    //float cluster_timing, io_timing;      

    /* obtain command line arguments and change appropriate options */
    while ( (opt=getopt(argc,argv,"i:t:m:n:l:bro"))!= EOF) {
    switch (opt) {
        case 'i': filename=optarg;
                  break;
        case 'b': isBinaryFile = 1;
                  break;            
        case 't': threshold=atof(optarg);
                  break;
        case 'm': max_nclusters = atoi(optarg);
                  break;
        case 'n': min_nclusters = atoi(optarg);
                  break;
        case 'r': isRMSE = 1;
                  break;
        case 'o': isOutput = 1;
                  break;
        case 'l': nloops = atoi(optarg);
                  break;
        case '?': usage(argv);
                  break;
        default: usage(argv);
                  break;
    }
}

if (filename == 0) usage(argv);
}
//in continues

和错误:

error : argument of type "void (*)()" is incompatible with parameter of type "_beginthread_proc_type"

0 个答案:

没有答案