为什么你会在定义函数中声明变量? [英] Why would you declare variables in the middle of defining a function?

查看:111
本文介绍了为什么你会在定义函数中声明变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不修改code由的国际电联工作

I have to modify the code for the G722 codec made by the ITU at work.

我包含像这样的时髦真的函数的定义:

I contains realy funky function definitions like this one :

    int 
    main (argc, argv)
    int argc;
    char *argv[];
    {
    .
    .
    .
    }

为什么会有人用这样的语法?

Why would anybody use such a syntax?

推荐答案

我用谷歌搜索旧的C风格宣言就像是在评论认为找到了答案。

I found the answer by googling "Old C Style Declaration" like it was suggested in comments.

答案是:

旧式函数声明和定义使用略有不同的规则来声明不是由ANSI C标准的推荐语法参数。首先,旧式的声明没有参数列表。第二,在功能定义中,参数列,但其种类没有在参数表中声明。该类型声明precede构成函数体复合语句。旧风格的语法已过时,不应在新code使用。使用旧风格的语法code仍然支持,但是。

The old-style function declarations and definitions use slightly different rules for declaring parameters than the syntax recommended by the ANSI C standard. First, the old-style declarations don't have a parameter list. Second, in the function definition, the parameters are listed, but their types are not declared in the parameter list. The type declarations precede the compound statement constituting the function body. The old-style syntax is obsolete and should not be used in new code. Code using the old-style syntax is still supported, however.

这是从: http://msdn.microsoft.com/en-美国/库/ efx873ys.aspx

这篇关于为什么你会在定义函数中声明变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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