在Visual Studio 2008怪异的编译错误 [英] Weird compilation error in Visual Studio 2008

查看:163
本文介绍了在Visual Studio 2008怪异的编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在编译如下code的一个问题:

I have a problem compiling the following code:

#include <stdio.h>
#include <limits.h>
int main () {
    printf("short: [%d,%d]\n",SHRT_MIN,SHRT_MAX);
    printf("int: [%d, %d]\n",INT_MIN, INT_MAX);
    printf("long: [%d, %d]\n",LONG_MIN,LONG_MAX);
    int aa=017;
    printf("%d\n",aa);
    return 0;
}

错误消息是:

1>c:\tic\ex1\ex2\ex2.c(12) : error C2143: syntax error : missing ';' before 'type'
1>c:\tic\ex1\ex2\ex2.c(13) : error C2065: 'aa' : undeclared identifier

不过,编译因为这是罚款:

However, compilation for this is fine:

    #include <stdio.h>
    #include <limits.h>
    int main () {
        int aa=017;
        printf("short: [%d,%d]\n",SHRT_MIN,SHRT_MAX);
        printf("int: [%d, %d]\n",INT_MIN, INT_MAX);
        printf("long: [%d, %d]\n",LONG_MIN,LONG_MAX);
        printf("%d\n",aa);
        return 0;
    }

任何想法是什么问题?

Any idea what the issue is?

推荐答案

在C,变量previously不得不在范围的顶部声明,在执行任何code之前。这不是在C99的情况下(它的Visual Studio没有实现。)

In C, variables previously had to be declared at the top of the scope, before any code is executed. This isn't the case in C99 (which Visual Studio doesn't implement.)

这篇关于在Visual Studio 2008怪异的编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆