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

manting 2012-07-06 03:33:03
static void f(a, b)
register unsigned long *a;
register unsigned char *b;
{
......
return;
}

函数是声明没有定义参数的类型
而在函数声明和函数体的中间插入了两行参数的声明?
有人能解释下吗?
我还没见过这种写法
...全文
142 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
k_badboy 2012-07-06
  • 打赏
  • 举报
回复
早期的C写法,相当于
static void f(register unsigned long *a, register unsigned char *b)
{
//.....
return;
}

CppCoder 2012-07-06
  • 打赏
  • 举报
回复
C语言的函数申明,
静态,无返回值,两个存放在寄存器的参数,一个参数保存无符号长整形数据地址,一个参数保存无符号字符型数据地址
alexander_david 2012-07-06
  • 打赏
  • 举报
回复
很古老的写法。
dahaiI0 2012-07-06
  • 打赏
  • 举报
回复
赵老师果然霸气。。。
看不懂,懒得去看。
stjay 2012-07-06
  • 打赏
  • 举报
回复
K&R C 语法
现在基本是ANSI C
赵4老师 2012-07-06
  • 打赏
  • 举报
回复
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.
manting 2012-07-06
  • 打赏
  • 举报
回复
这是什么写法呢?
教科书和参考书都没介绍过的
Barcode 2012-07-06
  • 打赏
  • 举报
回复
你编译能通过吗??
august_zhao 2012-07-06
  • 打赏
  • 举报
回复
寄存器变量 频繁使用的情况下提高效率

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧