C variable declarations after function header in definition

While reading some FreeBSD source code (see: radix.h lines 158-173), I found variable declarations that followed the "function header" in the definition.

Is this really in ISO C (C99)? when should this be done in production code instead of simply declaring variables inside the "function header"? Why is this done here?

I am referring to a function, a line header, that looks like this: int someFunction(int i, int b) {

+2
source share
3 answers

It looks like a K & R (pre-ANSI) style. I don't think this is really a C99, but do they use a C99? Joel

+8
source

I think you mean the "old-fashioned" ANS ANSI method for declaring parameters in C. It looked something like this:

int foo(a, b)
    int a,
    int b
{
    /* ... */
}

This may still be valid on C99 and will be accepted by compilers for backward compatibility reasons, but this should be considered obsolete / archaic.

+7
source

Er. Perhaps I do not understand your question, but iand bin this passage are the parameters of the function. This is not some compact way to declare variables inside a function, for example:

int someFunction() {
    int i, b;

When you call someFunction, you pass it these arguments:

someFunction(1, 2); // `i` will be `1` and `b` `2` within `someFunction`
0
source

All Articles