简体   繁体   中英

Why does msvc throw C2143 error

This code throws C2143 on vs2008 amd64 (python 2.7 compiler)

(4) : error C2143: syntax error : missing ';' before 'type'

int f(double B)
{
    B = B;
    double largest;
    return B;
}

This change removes the error:

int f(double B)
{
    double largest;
    B = B;        
    return B;
}

Can anyone explain the issue? I must be going crazy.

cl.exe /c test_p.c

在某些C版本中,必须在函数的开头声明所有变量,这就是为什么第一个示例生成错误而第二个示例不生成错误的原因。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM