error C2143: 语法错误 : 缺少“;”(在“类型”的前面)

C编程老是遇到这个问题:

错误    1    error C2143: 语法错误 : 缺少“;”(在“类型”的前面)    d:\kinectproject\ceshiglad\ceshiglad\shili.c    24    1    ceshiGLAD
#include <stdio.h>
#include <math.h>
#include <malloc.h>
#include "data.h"

double Alpha[5]={1,1,1,1,1};
double Beta[10]={1,1,1,1,1,1,1,1,1,1};
double Z1[10]={1,0,1,0,1,0,1,0,1,0};
double labels[150]={0,0,0,0,0,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0};

void main(){
    
    int i,j;
    double *rawPriorBeta = Beta;
    double *rawPriorZ1 = Z1;
    double *rawLabels = labels;
    double *rawPriorAlpha = Alpha;
    Dataset data;
    data.numLabels = 50;
    data.numLabelers = 5;
    data.numImages = 10;
    data.priorZ1 = (double *) malloc(sizeof(double) * data.numImages);
    data.priorAlpha = (double *) malloc(sizeof(double) * data.numLabelers);
    data.priorBeta = (double *) malloc(sizeof(double) * data.numImages);
    
    for (i = 0; i < data.numLabelers; i++) {
        data.priorAlpha[i] = rawPriorAlpha[i];
    }
    
    for (j = 0; j < data.numImages; j++) {
        data.priorBeta[j] = rawPriorBeta[j];
        data.priorZ1[j] = rawPriorZ1[j];
    }

    data.probZ1 = (double *) malloc(sizeof(double) * data.numImages);
    data.probZ0 = (double *) malloc(sizeof(double) * data.numImages);
    data.beta = (double *) malloc(sizeof(double) * data.numImages);
    data.alpha = (double *) malloc(sizeof(double) * data.numLabelers);
    data.labels = (Label *) malloc(sizeof(Label) * data.numLabels);

    
    for (i = 0; i < data.numLabels; i++) {
        /* Remember that Matlab stores data in row-major order! */
        data.labels[i].imageIdx = rawLabels[i];
        data.labels[i].labelerId = rawLabels[data.numLabels + i];
        data.labels[i].label = rawLabels[2 * data.numLabels + i];
    }
}

后来发现,把变量的声明放到main函数的前面,就不会有这个问题了,虽然不知道为什么,但是记一下。

 

转载于:https://www.cnblogs.com/rong86/p/3713341.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值