0

What is this C syntax from bash source code. it looks like a function definition where there are no types for the arguments but the types are defined on the next line

    static void
    add_temp_array_to_env(temp_array, do_alloc, do_supercede)
    char **temp_array;
    int do_alloc, do_supercede;
    {
        register int i;

        if (temp_array == 0)
            return;

        for (i = 0; temp_array[i]; i++)
        {
            if (do_supercede)
                export_env = add_or_supercede_exported_var(temp_array[i], do_alloc);
            else
                add_to_export_env(temp_array[i], do_alloc);
        }

        free(temp_array);
    }
jw56578
  • 400
  • 1
  • 13

1 Answers1

3

That is a pre-standard C definition, also known as K&R style.

It's equal to

static void add_temp_array_to_env(char **temp_array, int do_alloc, int do_supercede)
{
    ...
}
Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • 1
    It's not just pre-standard. ISO C, up to and including C11, still permits this old form (though it's "obsolescent"). But it's not exactly equivalent as a declaration. With a prototype, a call with arguments of the wrong type is a constraint violation and must be diagnosed. With a non-prototype declaration, such a call need not be diagnosed and has undefined behavior (and compilers I've used will not diagnose it). Also, arguments of types narrower than int or double are promoted when passed to a non-prototyped function. – Keith Thompson Jul 26 '18 at 21:30