开发者

Special parameters declaration function in C [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicates:

C function syntax, parameter types declared after parameter list

What is useful about this C syntax?

Why are declarations put between func() and {}?

Hi guys,

I downloaded the glibc. I want to reuse some code part from this librairy, but there is somethings weird in this 开发者_开发技巧code. In fact, the parameters declaration are strange. The type of the parameters declared after que parantheses. I never saw that before. What is this kind of declaration? I not am able to compile it.

void
_ufc_doit_r(itr, __data, res)
     ufc_long itr, *res;
     struct crypt_data * __restrict __data;
{
/*CODE HERE */
}


This is called "K&R" style, from Kernighan and Ritchie, who wrote the book The C Programming Language. In the first edition of that book, the above was the only way to declare the types of parameters. I believe the second edition uses the standard style, with the types and names both within parentheses:

void
_ufc_doit_r(ufc_long itr,
            struct crypt_data * __restrict __data,
            ufc_long *res)
{
/*CODE HERE */
}

K&R style is a very old style of declaring parameters, but some people still use it so their code can compile on very old compilers.


That's the old style of declaring the datatypes for the arguments. It's modern equivelent would be:

void
_ufc_doit_r(
     ufc_long itr,
     struct crypt_data * __restrict __data,
     ufc_long res
)
{
/*CODE HERE */
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜