Syntax error : missing ';' before 'type'

后端 未结 2 1085
野性不改
野性不改 2020-12-30 21:56

So i have this error:

Error 3 error C2143: syntax error : missing \';\' before \'type\' g:\\lel\\tommy\\tommy\\tommy.c 34 tommy

2条回答
  •  醉话见心
    2020-12-30 22:39

    When compiling a C program, MSVC doesn't allow declarations to follow statements in a block (it uses old C90 rules - support for declarations mixed with statements was added to C in the 1999 standard).

    Move the declaration of double *ptr to the top of matrix_read():

    int matrix_read(struct matrep *mat, const char *filename)
    {
        FILE *fptr;
        unsigned m, n;
        double *ptr = NULL;
    
        // ...
    
        ptr = mat->matrix;  //this is where the error used to occur
    
        // ...
    }
    

    I really wish MS would implement this 'extension' to their C compiler.

提交回复
热议问题