首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

请教这是函数的什么写法?以前没见过

2012-10-31 
请问这是函数的什么写法?以前没见过static void f(a, b)register unsigned long *aregister unsigned cha

请问这是函数的什么写法?以前没见过
static void f(a, b)
register unsigned long *a;
register unsigned char *b;
{
......
return;
}

函数是声明没有定义参数的类型
而在函数声明和函数体的中间插入了两行参数的声明?
有人能解释下吗?
我还没见过这种写法

[解决办法]
寄存器变量 频繁使用的情况下提高效率
[解决办法]
你编译能通过吗??
[解决办法]
Obsolete Forms of Function Declarations and Definitions
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. This example illustrates the obsolete forms of declarations and definitions:

double old_style(); /* Obsolete function declaration */

double alt_style( a , real ) /* Obsolete function definition */
double *real; 
int a; 
{
return ( *real + a ) ;
}

Functions returning an integer or pointer with the same size as an int are not required to have a declaration although the declaration is recommended. 

To comply with the ANSI C standard, old-style function declarations using an ellipsis now generate an error when compiling with the /Za option and a level 4 warning when compiling with /Ze. For example:

void funct1( a, ... ) /* Generates a warning under /Ze or */
int a; /* an error when compiling with /Za */
{
}

You should rewrite this declaration as a prototype:

void funct1( int a, ... )
{
}

Old-style function declarations also generate warnings if you subsequently declare or define the same function with either an ellipsis or a parameter with a type that is not the same as its promoted type. 

The next section, C Function Definitions, shows the syntax for function definitions, including the old-style syntax. The nonterminal for the list of parameters in the old-style syntax is identifier-list.

[解决办法]
K&R C 语法
现在基本是ANSI C
[解决办法]
赵老师果然霸气。。。
看不懂,懒得去看。
[解决办法]
很古老的写法。
[解决办法]
C语言的函数申明,
静态,无返回值,两个存放在寄存器的参数,一个参数保存无符号长整形数据地址,一个参数保存无符号字符型数据地址
[解决办法]
早期的C写法,相当于
static void f(register unsigned long *a, register unsigned char *b)
{
//.....
return;
}
 

热点排行